diff --git a/CMakeLists.txt b/CMakeLists.txt index b3577e8..3efcbd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,113 +1,111 @@ # Top level CMakeLists.txt for EvtGen # Enforce an out-of-source build. # Should be the first action in the top level CMakeLists.txt if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(STATUS "EvtGen requires an out-of-source build.") message(STATUS "Please remove the following files from ${CMAKE_BINARY_DIR}:") message(STATUS " CMakeCache.txt") message(STATUS " CMakeFiles") message(STATUS "Once these files are removed, create a separate directory") message(STATUS "and run CMake from there, pointing it to:") message(STATUS " ${CMAKE_SOURCE_DIR}") message(FATAL_ERROR "in-source build detected") endif() # Also require a minimum version of CMake cmake_minimum_required(VERSION 3.11.0) # Project setup if(${CMAKE_VERSION} VERSION_LESS 3.12.0) project(EvtGen VERSION 2.0.0 DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." ) else() project(EvtGen VERSION 2.0.0 DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." HOMEPAGE_URL "https://evtgen.hepforge.org" ) endif() # Prepend this project's custom module path(s) to CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) # Include needed modules to perform any custom setup # Install paths include(GNUInstallDirs) # Compilation/linking flags and related settings include(CompilerFlags) # EvtGen external dependencies option(EVTGEN_PYTHIA "Enable/disable linking with Pythia8" OFF) option(EVTGEN_PHOTOS "Enable/disable linking with Photos++" OFF) option(EVTGEN_TAUOLA "Enable/disable linking with Tauola++" OFF) option(EVTGEN_HEPMC3 "Enable/disable linking with HepMC3" ON) if (EVTGEN_HEPMC3) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEVTGEN_HEPMC3") -find_package(HepMC3 REQUIRED) message(STATUS "EvtGen: Linking with HepMC3") else() message(STATUS "EvtGen: Linking with HepMC2") endif() message(STATUS "EvtGen: Optional linking with Pythia8 EVTGEN_PYTHIA ${EVTGEN_PYTHIA}") message(STATUS "EvtGen: Optional linking with Photos++ EVTGEN_PHOTOS ${EVTGEN_PHOTOS}") message(STATUS "EvtGen: Optional linking with Tauola++ EVTGEN_TAUOLA ${EVTGEN_TAUOLA}") message(STATUS "EvtGen: Optional linking with HepMC3 EVTGEN_HEPMC3 ${EVTGEN_HEPMC3}") include(ExternalDependencies) # Now build the library add_subdirectory(src) # Copy the particle property and decay tables configure_file(DECAY.DEC ${CMAKE_CURRENT_BINARY_DIR}/DECAY.DEC COPYONLY) configure_file(DECAY.XML ${CMAKE_CURRENT_BINARY_DIR}/DECAY.XML COPYONLY) configure_file(evt.pdl ${CMAKE_CURRENT_BINARY_DIR}/evt.pdl COPYONLY) # Build the executables in the test and validation directories option(EVTGEN_BUILD_TESTS "Enable/disable building of executables in 'test' directory" OFF) option(EVTGEN_BUILD_VALIDATIONS "Enable/disable building of executables in 'validation' directory" OFF) message(STATUS "EvtGen: Building of executables in 'test' directory EVTGEN_BUILD_TESTS ${EVTGEN_BUILD_TESTS}") message(STATUS "EvtGen: Building of executables in 'validation' directory EVTGEN_BUILD_VALIDATIONS ${EVTGEN_BUILD_VALIDATIONS}") if(${EVTGEN_BUILD_TESTS}) add_subdirectory(test) endif() if(${EVTGEN_BUILD_VALIDATIONS}) add_subdirectory(validation) endif() # Install the include directories install(DIRECTORY EvtGen DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenBase DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenExternal DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY EvtGenModels DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Install the particle properties and decay tables -install(FILES DECAY.DEC DECAY.XML evt.pdl DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES DECAY.DEC DECAY.XML evt.pdl DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen) # Generate CMake config files, which can be used by other projects include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) configure_package_config_file(cmake/Templates/EvtGenConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake INSTALL_DESTINATION cmake PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR ) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake COMPATIBILITY AnyNewerVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/cmake ) install( EXPORT "EvtGenTargets" NAMESPACE "EvtGen::" DESTINATION ${CMAKE_INSTALL_DATADIR}/EvtGen/cmake ) diff --git a/setupEvtGen.sh b/setupEvtGen.sh index 7ddf3bf..5057a00 100644 --- a/setupEvtGen.sh +++ b/setupEvtGen.sh @@ -1,158 +1,158 @@ #!/bin/bash # This script installs EvtGen with all external dependencies. The variable VERSION specifies the # tag of EvtGen you want to use. The list of available tags can be found by either going to the url # https://phab.hepforge.org/source/evtgen/tags/master # or issuing the command (without the need to clone the git repository) # git ls-remote --tags http://phab.hepforge.org/source/evtgen.git | cut -d '/' -f3 # Note that some earlier EvtGen versions will not be compatible with all external dependency # versions given below, owing to C++ interface differences; see the specific tagged version of # the EvtGen/README file for guidance. # To obtain this script use the "Download File" option on the right of the webpage: # https://phab.hepforge.org/source/evtgen/browse/master/setupEvtGen.sh?view=raw # Version or tag number. No extra spaces on this line! VERSION=cmake # Pythia version number with no decimal points, e.g. 8230 corresponds to version 8.230. This # follows the naming convention of Pythia install tar files. Again, no extra spaces allowed PYTHIAVER=8230 PYTHIAPKG="pythia"$PYTHIAVER PYTHIATAR=$PYTHIAPKG".tgz" echo Pythia version set to $PYTHIAVER, package tar name $PYTHIATAR HEPMCMAJORVERSION="3" mkdir -p EvtGen cd EvtGen INSTALL_BASE=`pwd` echo Will setup EvtGen $VERSION in $INSTALL_BASE echo Downloading EvtGen from GIT git clone https://phab.hepforge.org/source/evtgen.git evtgen.git cd evtgen.git #git checkout -b $VERSION $VERSION git checkout $VERSION cd $INSTALL_BASE # Replace the above lines with the following one for the "head" version #git clone http://phab.hepforge.org/source/evtgen.git evtgen.git osArch=`uname` echo Downloading external dependencies mkdir -p external cd external # Recommended versions of the external packages. HepMC is mandatory. # Later versions should be OK as well, assuming their C++ interfaces do not change curl -O http://hepmc.web.cern.ch/hepmc/releases/hepmc2.06.10.tgz curl -O http://hepmc.web.cern.ch/hepmc/releases/HepMC3-3.2.0.tar.gz curl -O http://home.thep.lu.se/~torbjorn/pythia8/$PYTHIATAR curl -O http://photospp.web.cern.ch/photospp/resources/PHOTOS.3.64/PHOTOS.3.64.tar.gz curl -O http://tauolapp.web.cern.ch/tauolapp/resources/TAUOLA.1.1.8/TAUOLA.1.1.8.tar.gz echo Extracting external dependencies tar -xzf hepmc2.06.10.tgz tar -xzf HepMC3-3.2.0.tar.gz tar -xzf $PYTHIATAR tar -xzf PHOTOS.3.61.tar.gz tar -xzf TAUOLA.1.1.6c.tar.gz # Patch TAUOLA and PHOTOS on Darwin (Mac) if [ "$osArch" == "Darwin" ] then patch -p0 < $INSTALL_BASE/evtgen.git/platform/tauola_Darwin.patch patch -p0 < $INSTALL_BASE/evtgen.git/platform/photos_Darwin.patch fi if [ "$HEPMCMAJORVERSION" -lt "3" ] then echo Installing HepMC in $INSTALL_BASE/external/HepMC mkdir -p HepMC mkdir -p HepMC.build cd HepMC.build cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/external/HepMC $INSTALL_BASE/external/hepmc2.06.10 -Dmomentum:STRING=GEV -Dlength:STRING=MM make make install echo Installing pythia8 in $INSTALL_BASE/external/$PYTHIAPKG cd ../$PYTHIAPKG if [ "$PYTHIAVER" -lt "8200" ] then ./configure --with-hepmc=$INSTALL_BASE/external/HepMC --with-hepmcversion=2.06.10 --enable-shared else ./configure --with-hepmc2=$INSTALL_BASE/external/HepMC --enable-shared fi make echo Installing PHOTOS in $INSTALL_BASE/external/PHOTOS cd ../PHOTOS ./configure --with-hepmc=$INSTALL_BASE/external/HepMC make echo Installing TAUOLA in $INSTALL_BASE/external/TAUOLA cd ../TAUOLA ./configure --with-hepmc=$INSTALL_BASE/external/HepMC make else echo Installing HepMC3 in $INSTALL_BASE/external/HepMC3 mkdir -p HepMC3 mkdir -p HepMC3.build cd HepMC3.build cmake -DHEPMC3_ENABLE_ROOTIO=OFF -DHEPMC3_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/external/HepMC3 $INSTALL_BASE/external/HepMC3-3.2.0 make make install echo Installing pythia8 in $INSTALL_BASE/external/$PYTHIAPKG cd ../$PYTHIAPKG if [ "$PYTHIAVER" -lt "8200" ] then - ./configure + ./configure --enable-shared else ./configure --with-hepmc3=$INSTALL_BASE/external/HepMC3 --enable-shared fi make echo Installing PHOTOS in $INSTALL_BASE/external/PHOTOS -cd ../PHOTOS -./configure +cd ../PHOTOS +./configure --with-hepmc3=$INSTALL_BASE/external/HepMC3 make echo Installing TAUOLA in $INSTALL_BASE/external/TAUOLA cd ../TAUOLA -./configure +./configure --with-hepmc3=$INSTALL_BASE/external/HepMC3 make fi echo Building EvtGen cd $INSTALL_BASE mkdir -p evtgen.build mkdir -p evtgen cd evtgen.build if [ "$HEPMCMAJORVERSION" -lt "3" ] then cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/evtgen $INSTALL_BASE/evtgen.git -DEVTGEN_PYTHIA=ON -DEVTGEN_PHOTOS=ON -DEVTGEN_TAUOLA=ON -DEVTGEN_HEPMC3=OFF else cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/evtgen $INSTALL_BASE/evtgen.git -DEVTGEN_PYTHIA=ON -DEVTGEN_PHOTOS=ON -DEVTGEN_TAUOLA=ON fi make make install cd $INSTALL_BASE/evtgen echo Setup done. echo To complete, set the Pythia8 data path: if [ "$PYTHIAVER" -lt "8200" ] then echo PYTHIA8DATA=$INSTALL_BASE/external/$PYTHIAPKG/xmldoc else echo PYTHIA8DATA=$INSTALL_BASE/external/$PYTHIAPKG/share/Pythia8/xmldoc fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dbda781..650b482 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,159 +1,161 @@ # Use glob to find the sources for the main and external libraries file(GLOB EVTGEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenBase/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenModels/*.cpp ) file(GLOB EVTGEN_EXTERNAL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenExternal/*.cpp ) # Add the main EvtGen library... add_library(objlib OBJECT ${EVTGEN_SOURCES}) set_target_properties(objlib PROPERTIES POSITION_INDEPENDENT_CODE 1) target_include_directories(objlib PRIVATE ${CMAKE_SOURCE_DIR}) target_compile_definitions(objlib PRIVATE EVTGEN_CPP11) if (EVTGEN_HEPMC3) +target_compile_definitions(objlib PRIVATE EVTGEN_HEPMC3) target_include_directories(objlib PRIVATE ${HEPMC3_INCLUDE_DIR}) else() target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) endif() add_library(EvtGen SHARED $) set_target_properties(EvtGen PROPERTIES OUTPUT_NAME EvtGen) set_target_properties(EvtGen PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) set_target_properties(EvtGen PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) target_include_directories(EvtGen PUBLIC $ $) if (EVTGEN_HEPMC3) target_include_directories(EvtGen PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGen ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) else() target_include_directories(EvtGen PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGen ${HEPMC2_LIBRARIES}) endif() target_compile_definitions(EvtGen PUBLIC EVTGEN_CPP11) add_library(EvtGenStatic STATIC $) set_target_properties(EvtGenStatic PROPERTIES OUTPUT_NAME EvtGen) set_target_properties(EvtGenStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/archive) target_include_directories(EvtGenStatic PUBLIC $ $) if (EVTGEN_HEPMC3) target_include_directories(EvtGenStatic PUBLIC ${HEPMC3_INCLUDE_DIR}) target_link_libraries(EvtGenStatic ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) else() target_include_directories(EvtGenStatic PUBLIC ${HEPMC2_INCLUDE_DIR}) target_link_libraries(EvtGenStatic ${HEPMC2_LIBRARIES}) endif() target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_CPP11) # Add the EvtGenExternal library... if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) add_library(objlib_ext OBJECT ${EVTGEN_EXTERNAL_SOURCES}) set_target_properties(objlib_ext PROPERTIES POSITION_INDEPENDENT_CODE 1) target_include_directories(objlib_ext PRIVATE ${CMAKE_SOURCE_DIR}) if (EVTGEN_HEPMC3) target_include_directories(objlib_ext PUBLIC ${HEPMC3_INCLUDE_DIR}) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_HEPMC3) else() target_include_directories(objlib_ext PUBLIC ${HEPMC2_INCLUDE_DIR}) endif() target_compile_definitions(objlib_ext PRIVATE EVTGEN_CPP11) if(${EVTGEN_PYTHIA}) target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIRS}) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PYTHIA) endif() if(${EVTGEN_PHOTOS}) target_include_directories(objlib_ext PRIVATE ${Photos++_INCLUDE_DIRS}) target_compile_definitions(objlib_ext PRIVATE EVTGEN_PHOTOS) endif() if(${EVTGEN_TAUOLA}) target_include_directories(objlib_ext PRIVATE ${Tauola++_INCLUDE_DIRS}) target_compile_definitions(objlib_ext PRIVATE EVTGEN_TAUOLA) endif() add_library(EvtGenExternal SHARED $) set_target_properties(EvtGenExternal PROPERTIES OUTPUT_NAME EvtGenExternal) set_target_properties(EvtGenExternal PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) set_target_properties(EvtGenExternal PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) if(${EVTGEN_PYTHIA}) target_link_libraries(EvtGenExternal ${PYTHIA8_LIBRARIES}) endif() if (EVTGEN_HEPMC3) target_link_libraries(EvtGenExternal ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) if(${EVTGEN_PHOTOS}) target_link_libraries(EvtGenExternal ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY} ) endif() if(${EVTGEN_TAUOLA}) target_link_libraries(EvtGenExternal ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) endif() else() target_link_libraries(EvtGenExternal ${HEPMC2_LIBRARIES}) if(${EVTGEN_PHOTOS}) #Photos should always have ppHepMC for compilation with HepMC2 target_link_libraries(EvtGenExternal ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) endif() if(${EVTGEN_TAUOLA}) target_link_libraries(EvtGenExternal ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) #The old versions of Tauola don't have HepMC, the HepMC2 interface is in CxxInterface if (Tauola++_HepMC_FOUND) target_link_libraries(EvtGenExternal ${Tauola++_HepMC_LIBRARY}) endif() endif() endif() add_library(EvtGenExternalStatic STATIC $) set_target_properties(EvtGenExternalStatic PROPERTIES OUTPUT_NAME EvtGenExternal) set_target_properties(EvtGenExternalStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/archive) if(${EVTGEN_PYTHIA}) target_link_libraries(EvtGenExternalStatic ${PYTHIA8_LIBRARIES}) endif() if (EVTGEN_HEPMC3) target_link_libraries(EvtGenExternalStatic ${HEPMC3_LIB} ${HEPMC3_SEARCH_LIB} ) if(${EVTGEN_PHOTOS}) target_link_libraries(EvtGenExternalStatic ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC3_LIBRARY}) endif() if(${EVTGEN_TAUOLA}) target_link_libraries(EvtGenExternalStatic ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY} ${Tauola++_HepMC3_LIBRARY}) endif() else() if(${EVTGEN_PHOTOS}) target_link_libraries(EvtGenExternalStatic ${Photos++_pp_LIBRARY} ${Photos++_ppHepMC_LIBRARY}) endif() if(${EVTGEN_TAUOLA}) target_link_libraries(EvtGenExternalStatic ${Tauola++_CxxInterface_LIBRARY} ${Tauola++_Fortran_LIBRARY}) if (Tauola++_HepMC_FOUND) target_link_libraries(EvtGenExternalStatic ${Tauola++_HepMC_LIBRARY} ) endif() endif() target_link_libraries(EvtGenExternalStatic ${HEPMC2_LIBRARIES}) endif() endif() # Install the libraries install( TARGETS EvtGen EvtGenStatic EXPORT "EvtGenTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/archive ) if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) install( TARGETS EvtGenExternal EvtGenExternalStatic EXPORT "EvtGenTargets" LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/archive ) endif() diff --git a/src/EvtGenBase/EvtHepMCEvent.cpp b/src/EvtGenBase/EvtHepMCEvent.cpp index 87a7b58..3c54b6b 100644 --- a/src/EvtGenBase/EvtHepMCEvent.cpp +++ b/src/EvtGenBase/EvtHepMCEvent.cpp @@ -1,197 +1,197 @@ //-------------------------------------------------------------------------- // // Environment: // This software is part of the EvtGen package. If you use all or part // of it, please give an appropriate acknowledgement. // // Copyright Information: See EvtGen/COPYRIGHT // Copyright (C) 2011 University of Warwick, UK // // Module: EvtHepMCEvent // // Description: Create an HepMC::GenEvent for the complete EvtParticle // decay tree. // // Modification history: // // John Back June 2011 Module created // //------------------------------------------------------------------------ #include "EvtGenBase/EvtPatches.hh" #include "EvtGenBase/EvtHepMCEvent.hh" #include "EvtGenBase/EvtParticle.hh" #include "EvtGenBase/EvtPDL.hh" EvtHepMCEvent::EvtHepMCEvent() : _theEvent(0), _translation(0.0, 0.0, 0.0, 0.0) { } EvtHepMCEvent::~EvtHepMCEvent() { this->deleteEvent(); } void EvtHepMCEvent::deleteEvent() { if (_theEvent != 0) { _theEvent->clear(); delete _theEvent; _theEvent = 0; } } void EvtHepMCEvent::constructEvent(EvtParticle* baseParticle) { EvtVector4R origin(0.0, 0.0, 0.0, 0.0); this->constructEvent(baseParticle, origin); } void EvtHepMCEvent::constructEvent(EvtParticle* baseParticle, EvtVector4R& translation) { // This class does not take ownership of the base particle pointer. // Rather, it uses the base particle to construct the event. this->deleteEvent(); if (baseParticle == 0) {return;} _theEvent = new GenEvent(Units::GEV, Units::MM); _translation = translation; // Use the recursive function addVertex to add a vertex with incoming/outgoing // particles. Adds a new vertex for any EvtParticles with decay daughters. // All particles are in the rest frame of the base particle ("lab frame"). GenParticlePtr hepMCGenParticle = this->createGenParticle(baseParticle, EvtHepMCEvent::LAB); this->addVertex(baseParticle, hepMCGenParticle); } GenParticlePtr EvtHepMCEvent::createGenParticle(EvtParticle* theParticle, int frameType) { // Create an HepMC GenParticle, with the 4-momenta in the frame given by the frameType integer - GenParticlePtr genParticle; + GenParticlePtr genParticle{nullptr}; if (theParticle != 0) { // Set the particle status integer to either stable or decayed int status(EvtHepMCEvent::STABLE); int nDaug = theParticle->getNDaug(); if (nDaug > 0) {status = EvtHepMCEvent::DECAYED;} // Get the 4-momentum (E, px, py, pz) for the EvtParticle. EvtVector4R p4(0.0, 0.0, 0.0, 0.0); if (frameType == EvtHepMCEvent::RESTFRAME) { p4 = theParticle->getP4Restframe(); } else if (frameType == EvtHepMCEvent::LAB) { p4 = theParticle->getP4Lab(); } else { p4 = theParticle->getP4(); } // Convert this to the HepMC 4-momentum double E = p4.get(0); double px = p4.get(1); double py = p4.get(2); double pz = p4.get(3); FourVector hepMC_p4(px, py, pz, E); // Get the particle PDG integer id int PDGInt = EvtPDL::getStdHep(theParticle->getId()); genParticle = newGenParticlePtr(hepMC_p4, PDGInt, status); } return genParticle; } void EvtHepMCEvent::addVertex(EvtParticle* inEvtParticle, GenParticlePtr inGenParticle) { // This is a recursive function that adds GenVertices to the GenEvent for // the incoming EvtParticle and its daughters. We use two separate // pointers for the EvtParticle and GenParticle information: the former // to obtain the PDGId, 4-momenta, daughter and vertex positions, the latter to // set the incoming particle to the vertex. Note that the outgoing particle for // one vertex might be the incoming particle for another vertex - this needs to // be the same GenParticle pointer, hence the reason for using it as a 2nd argument // in this function. if (_theEvent == 0 || inEvtParticle == 0 || inGenParticle == 0) {return;} // Create the decay vertex FourVector vtxCoord = this->getVertexCoord(inEvtParticle); GenVertexPtr theVertex = newGenVertexPtr(vtxCoord); // Add the vertex to the event _theEvent->add_vertex(theVertex); // Set the incoming particle theVertex->add_particle_in(inGenParticle); // Set the outgoing particles (decay products) int nDaug = inEvtParticle->getNDaug(); int iDaug(0); // Loop over the daughters for (iDaug = 0; iDaug < nDaug; iDaug++) { EvtParticle* evtDaughter = inEvtParticle->getDaug(iDaug); GenParticlePtr genDaughter = this->createGenParticle(evtDaughter, EvtHepMCEvent::LAB); if (genDaughter != 0) { // Add a new GenParticle (outgoing) particle daughter to the vertex theVertex->add_particle_out(genDaughter); // Find out if the daughter also has decay products. // If so, recursively run this function again. int nDaugProducts = evtDaughter->getNDaug(); if (nDaugProducts > 0) { // Recursively process daughter particles and add their vertices to the event this->addVertex(evtDaughter, genDaughter); } // Have daughter products } // hepMCDaughter != 0 } // Loop over daughters } FourVector EvtHepMCEvent::getVertexCoord(EvtParticle* theParticle) { FourVector vertexCoord(0.0, 0.0, 0.0, 0.0); if (theParticle != 0 && theParticle->getNDaug() != 0) { // Get the position (t,x,y,z) of the EvtParticle, offset by the translation vector. // This position will be the point where the particle decays. So we ask // the position of the (1st) daughter particle. EvtParticle* daugParticle = theParticle->getDaug(0); if (daugParticle != 0) { EvtVector4R vtxPosition = daugParticle->get4Pos() + _translation; // Create the HepMC 4 vector of the position (x,y,z,t) vertexCoord.setX(vtxPosition.get(1)); vertexCoord.setY(vtxPosition.get(2)); vertexCoord.setZ(vtxPosition.get(3)); vertexCoord.setT(vtxPosition.get(0)); } } return vertexCoord; } \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1c403ad..2f18f47 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,30 +1,33 @@ # the test executables require ROOT for histogramming etc. find_package(ROOT QUIET COMPONENTS Hist) if (ROOT_FOUND) add_library(root_interface INTERFACE IMPORTED) target_include_directories(root_interface INTERFACE ${ROOT_INCLUDE_DIRS}) target_link_libraries(root_interface INTERFACE ${ROOT_LIBRARIES}) # build each of the executables foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC ) add_executable(${test_exe} ${test_exe}.cc) target_link_libraries(${test_exe} PRIVATE EvtGen) if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) target_compile_definitions(${test_exe} PRIVATE EVTGEN_EXTERNAL) target_link_libraries(${test_exe} PRIVATE EvtGenExternal) + if (EVTGEN_HEPMC3) + target_compile_definitions(${test_exe} PRIVATE EVTGEN_HEPMC3) + endif() endif() target_link_libraries(${test_exe} PRIVATE root_interface) endforeach() # install the executables install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC RUNTIME DESTINATION test ) # install the decay files, macros, scripts, etc. install(DIRECTORY exampleFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/test) install(FILES do_tests DESTINATION ${CMAKE_INSTALL_PREFIX}/test PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) endif() \ No newline at end of file