Commit 81433dd2 authored by Andrii Verbytskyi's avatar Andrii Verbytskyi

To version 3.1.1

parent 200288f8
......@@ -23,7 +23,7 @@ find_path(PYTHIA8_INCLUDE_DIR Pythia.h Pythia8/Pythia.h
HINTS ${PYTHIA8_ROOT_DIR}/include)
find_path(PYTHIA8_XMLDOC_DIR Version.xml
HINTS ${PYTHIA8_ROOT_DIR}/xmldoc ${PYTHIA8_ROOT_DIR}/share/Pythia8/xmldoc ${PYTHIA8_ROOT_DIR}/share/pythia8-data/xmldoc)
HINTS ${PYTHIA8_ROOT_DIR}/xmldoc ${PYTHIA8_ROOT_DIR}/share/Pythia8/xmldoc ${PYTHIA8_ROOT_DIR}/share/pythia8-data/xmldoc ${PYTHIA8_ROOT_DIR}/share/doc/packages/pythia/xmldoc )
if(PYTHIA8_INCLUDE_DIR AND PYTHIA8_XMLDOC_DIR)
file(READ ${PYTHIA8_XMLDOC_DIR}/Version.xml versionstr)
......
@PACKAGE_INIT@
set_and_check(HEPMC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(HEPMC3_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
find_library(HEPMC_LIB NAMES HepMC HINTS @PACKAGE_LIB_INSTALL_DIR@)
find_library(HEPMC_ROOTIO_LIB NAMES HepMCrootIO HINTS @PACKAGE_LIB_INSTALL_DIR@)
find_library(HEPMC3_LIB NAMES HepMC3 HINTS @PACKAGE_LIB_INSTALL_DIR@)
find_library(HEPMC3_SEARCH_LIB NAMES HepMC3search HINTS @PACKAGE_LIB_INSTALL_DIR@)
find_library(HEPMC3_ROOTIO_LIB NAMES HepMC3rootIO HINTS @PACKAGE_LIB_INSTALL_DIR@ @PACKAGE_LIB_INSTALL_DIR@/root )
if(EXISTS ${HEPMC_ROOTIO_LIB})
set(HEPMC_LIBRARIES ${HEPMC_LIB} ${HEPMC_ROOTIO_LIB})
else()
set(HEPMC_LIBRARIES ${HEPMC_LIB})
set(HEPMC3_ROOT_DIR @CMAKE_INSTALL_PREFIX@)
set(HEPMC3_LIBRARIES ${HEPMC3_LIB})
if(EXISTS ${HEPMC3_SEARCH_LIB})
list( APPEND HEPMC3_LIBRARIES${HEPMC3_SEARCH_LIB})
endif()
if(EXISTS ${HEPMC3_ROOTIO_LIB})
list( APPEND HEPMC3_LIBRARIES ${HEPMC3_ROOTIO_LIB})
endif()
\ No newline at end of file
all: Doxyfile
doxygen Doxyfile
@echo "******************************************************"
@echo " Please load the doxygen documentation file "
@echo " documentation/html/index.html in your web browser "
@echo "******************************************************"
clean:
rm -rf html/
rm -f *~
......@@ -124,6 +124,44 @@
@note An interface to convert raw pointers to GenParticlePtr, GenVertexPtr
is available for backward-compatibility. It is marked as deprecated.
###########################################################################
@subsection iterators Iterators
###########################################################################
The iterator-bases classe and access functions from HepMC2, e.g.
@code{.cpp}
class particle_iterator;
class vertex_iterator;
class edge_iterator;
...
inline int GenEvent::particles_size() const;
inline int GenEvent::vertices_size() const;
...
@endcode
were removed.
The C++11 itarations should be used instead, e.g. instead of
@code{.cpp}
for (GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) {
...
}
@endcode
one should use
@code{.cpp}
for (auto p: evt->particles()) {
...
}
@endcode
or alternatively
@code{.cpp}
for (size_t i=0;i<evt->particles().size();++i) {
...
evt->particles().at(i)
...
}
@endcode
###########################################################################
@subsection topological_order Topological order
###########################################################################
......
......@@ -23,13 +23,14 @@
@subsection hepmc3_releases HepMC3 releases
<a href="https://gitlab.cern.ch/hepmc/HepMC3/blob/master/ChangeLog">ChangeLog</a>
- <a href="releases/hepmc3.0.0.tgz">hepmc3.0.0.tgz</a> HepMC3.0.0 <b> 20.Mar.2017</b>
- <a href="releases/hepmc3-beta2.0.tgz">hepmc3-beta2.0.tgz</a> HepMC3 beta2.0 <b> 25.Apr.2016</b>
- <a href="releases/hepmc3-beta1.0.tgz">hepmc3-beta1.0.tgz</a> HepMC3 beta1.0 <b> 13.Jan.2016</b>
- <a href="releases/hepmc3-alpha5.tgz">hepmc3-alpha5.tgz</a> HepMC3 alpha5 <b> 29.Apr.2015</b>
- <a href="releases/hepmc3-alpha4.tgz">hepmc3-alpha4.tgz</a> HepMC3 alpha4 <b> 7.Apr.2015</b>
- <a href="releases/hepmc3-alpha3.tgz">hepmc3-alpha3.tgz</a> HepMC3 alpha3 <b>10.Mar.2015</b>
- <a href="releases/hepmc3-alpha2.tgz">hepmc3-alpha2.tgz</a> HepMC3 alpha2 <b>15.Dec.2014</b>
- <a href="releases/HepMC3-3.1.0.tar.gz">HepMC-3.1.0.tar.gz</a> HepMC3-3.1.0 <b> 08.Feb.2019</b>
- <a href="releases/hepmc3.0.0.tgz">hepmc3.0.0.tgz</a> HepMC3-3.0.0 <b> 20.Mar.2017</b>
- <a href="releases/hepmc3-beta2.0.tgz">hepmc3-beta2.0.tgz</a> HepMC3-beta2.0 <b> 25.Apr.2016</b>
- <a href="releases/hepmc3-beta1.0.tgz">hepmc3-beta1.0.tgz</a> HepMC3-beta1.0 <b> 13.Jan.2016</b>
- <a href="releases/hepmc3-alpha5.tgz">hepmc3-alpha5.tgz</a> HepMC3-alpha5 <b> 29.Apr.2015</b>
- <a href="releases/hepmc3-alpha4.tgz">hepmc3-alpha4.tgz</a> HepMC3-alpha4 <b> 7.Apr.2015</b>
- <a href="releases/hepmc3-alpha3.tgz">hepmc3-alpha3.tgz</a> HepMC3-alpha3 <b>10.Mar.2015</b>
- <a href="releases/hepmc3-alpha2.tgz">hepmc3-alpha2.tgz</a> HepMC3-alpha2 <b>15.Dec.2014</b>
- <a href="releases/hepmc3-alpha1.tgz">hepmc3-alpha1.tgz</a> First alpha release of HepMC3 <b>6.Nov.2014</b>
@subsection hepmc2_releases HepMC2 releases
......
......@@ -19,7 +19,7 @@ endif()
if(CMAKE_Fortran_COMPILER)
add_executable(hepevt_wrapper_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/hepevt_wrapper_example_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/hepevt_wrapper_example_fortran.f)
target_link_libraries(hepevt_wrapper_example.exe HepMC3_static)
target_link_libraries(hepevt_wrapper_example.exe HepMC3)
set_target_properties(hepevt_wrapper_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
install(TARGETS hepevt_wrapper_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
......@@ -29,13 +29,13 @@ else()
endif()
add_executable(HepMC2_reader_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/HepMC2_reader_example.cc)
target_link_libraries(HepMC2_reader_example.exe HepMC3_static ${ROOT_LIBRARIES})
target_link_libraries(HepMC2_reader_example.exe HepMC3 ${ROOT_LIBRARIES})
set_target_properties(HepMC2_reader_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
install(TARGETS HepMC2_reader_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(HepMC3_fileIO_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/HepMC3_fileIO_example.cc)
target_link_libraries(HepMC3_fileIO_example.exe HepMC3_static ${ROOT_LIBRARIES})
target_link_libraries(HepMC3_fileIO_example.exe HepMC3 ${ROOT_LIBRARIES})
set_target_properties(HepMC3_fileIO_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
install(TARGETS HepMC3_fileIO_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
......@@ -3,6 +3,52 @@
cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
include_directories(${PROJECT_SOURCE_DIR}/include )
#This is needed for standalone compilation
if (USE_INSTALLED_HEPMC3)
find_package(HepMC3 REQUIRED)
include_directories(${HEPMC3_INCLUDE_DIR})
include(GNUInstallDirs)
if (HEPMC3_ROOTIO_LIB)
set (ROOT_FIND_COMPONENTS Core RIO Tree)
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
list(APPEND CMAKE_PREFIX_PATH ${ROOT_DIR})
find_package(ROOT REQUIRED COMPONENTS Core RIO Tree)
message(STATUS "ROOT_USE_FILE ${ROOT_USE_FILE}")
include(${ROOT_USE_FILE})
message(STATUS "ROOT includes: ${ROOT_INCLUDE_DIRS}")
message(STATUS "ROOT libraries: ${ROOT_LIBRARIES}")
message(STATUS "ROOT_FOUND: ${ROOT_FOUND}")
if(ROOT_FOUND)
include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(-DHEPMC3_ROOTIO)
set(HEPMC3_ROOTIO_LIBRARY ${HEPMC3_ROOTIO_LIB} )
endif()
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("/Zc:__cplusplus" COMPILER_SUPPORTS_ZCPLUSPLUS)
if(COMPILER_SUPPORTS_ZCPLUSPLUS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
endif()
endif()
#<-This is needed for standalone compilation
include(CheckLanguage)
check_language(Fortran)
if (CMAKE_Fortran_COMPILER)
......@@ -34,20 +80,13 @@ add_subdirectory(LHEFExample)
add_subdirectory(ConvertExample)
set(PYTHIA8_ROOT_DIR "" CACHE PATH "Location of Pythia8 installation.")
find_package(Pythia8 QUIET)
if(PYTHIA8_FOUND)
add_subdirectory(Pythia8Example)
else()
message(STATUS "Examples: Pythia8 package not found. Please check if PYTHIA8_ROOT_DIR is set properly.")
message(STATUS "pythia8_example disabled")
endif()
add_subdirectory(Pythia8Example)
if(ROOT_FOUND)
add_subdirectory(RootIOExample)
add_subdirectory(RootIOExample2)
add_subdirectory(RootIOExample3)
add_subdirectory(ViewerExample)
else()
message(STATUS "Examples: ROOT package not found. ")
message(STATUS "rootIO_example disabled")
......
......@@ -12,10 +12,11 @@ add_executable(convert_example.exe
${CMAKE_CURRENT_SOURCE_DIR}/convert_example.cc
${CMAKE_CURRENT_SOURCE_DIR}/cmdline.c
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterRootTreeOPAL.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterDOT.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterHEPEVTZEUS.cc )
target_link_libraries(convert_example.exe ${ROOT_LIBRARIES} HepMC3 HepMC3rootIO)
set_target_properties(convert_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
target_compile_definitions(convert_example.exe PRIVATE HEPMCCONVERT_EXTENSION_ROOTTREEOPAL=1 HEPMCCONVERT_EXTENSION_HEPEVTZEUS=1)
target_compile_definitions(convert_example.exe PRIVATE HEPMCCONVERT_EXTENSION_ROOTTREEOPAL=1 HEPMCCONVERT_EXTENSION_HEPEVTZEUS=1 HEPMCCONVERT_EXTENSION_DOT=1)
add_dependencies( convert_example.exe dictionary )
......@@ -32,26 +33,27 @@ include_directories(${PROJECT_SOURCE_DIR}/rootIO/include ${CMAKE_CURRENT_SOURCE_
add_executable(convert_example.exe
${CMAKE_CURRENT_SOURCE_DIR}/convert_example.cc
${CMAKE_CURRENT_SOURCE_DIR}/cmdline.c
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterDOT.cc
${CMAKE_CURRENT_SOURCE_DIR}/src/WriterHEPEVTZEUS.cc )
target_link_libraries(convert_example.exe HepMC3 )
set_target_properties(convert_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
target_compile_definitions(convert_example.exe PRIVATE HEPMCCONVERT_EXTENSION_HEPEVTZEUS=1)
target_compile_definitions(convert_example.exe PRIVATE HEPMCCONVERT_EXTENSION_HEPEVTZEUS=1 HEPMCCONVERT_EXTENSION_DOT=1)
# create environment scripts
set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/examples/ConvertExample/convert_example_env.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/convert_example_env.sh.in
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/convert_example_env.sh
@ONLY
)
# installs
install(TARGETS convert_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/examples/ConvertExample/ DESTINATION ${CMAKE_INSTALL_BINDIR} FILES_MATCHING PATTERN "*.pcm" PATTERN "*config" PATTERN "CMakeFiles" EXCLUDE )
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_BINDIR} FILES_MATCHING PATTERN "*.pcm" PATTERN "*config" PATTERN "CMakeFiles" EXCLUDE )
install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES_MATCHING PATTERN "*env.sh")
FILES_MATCHING PATTERN "*env.sh*")
......@@ -67,7 +69,7 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINA
# hepmcconvert -i hepmc2 -o treeroot input.hepmc output.root
#"
#option "input-format" i "Input format" string required values="hepmc2", "hepmc3", "hpe" ,"root", "treeroot","lhef"
#option "output-format" o "Output format" string required values="hepmc2", "hepmc3", "hpe" ,"root", "treeroot" ,"treerootopal","hpezeus", "dump"
#option "output-format" o "Output format" string required values="hepmc2", "hepmc3", "hpe" ,"root", "treeroot" ,"treerootopal","hpezeus", "dump", "dot"
#option "extensions" e "Extensions, in a form extension=value, could be passed to readers/writers" multiple optional string
#option "events-limit" - "Limit of events to read from input" optional long default="100000000"
#option "first-event-number" - "Lowest allowed event number" optional long default="-100000000"
......
......@@ -35,7 +35,7 @@ const char *gengetopt_args_info_description = "";
const char *gengetopt_args_info_help[] = {
" -h, --help Print help and exit",
" -i, --input-format=STRING Input format (possible values=\"hepmc2\",\n \"hepmc3\", \"hpe\", \"root\", \"treeroot\",\n \"lhef\") (mandatory)",
" -o, --output-format=STRING Output format (possible values=\"hepmc2\",\n \"hepmc3\", \"hpe\", \"root\", \"treeroot\",\n \"treerootopal\", \"hpezeus\", \"dump\")\n (mandatory)",
" -o, --output-format=STRING Output format (possible values=\"hepmc2\",\n \"hepmc3\", \"hpe\", \"root\", \"treeroot\",\n \"treerootopal\", \"hpezeus\", \"dump\",\n \"dot\", \"none\") (mandatory)",
" -e, --extensions=STRING Extensions, in a form extension=value, could be\n passed to readers/writers",
" --events-limit=LONG Limit of events to read from input\n (default=`100000000')",
" --first-event-number=LONG Lowest allowed event number\n (default=`-100000000')",
......@@ -62,7 +62,7 @@ static int
cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
const char *cmdline_parser_input_format_values[] = {"hepmc2", "hepmc3", "hpe", "root", "treeroot", "lhef", 0}; /*< Possible values for input-format. */
const char *cmdline_parser_output_format_values[] = {"hepmc2", "hepmc3", "hpe", "root", "treeroot", "treerootopal", "hpezeus", "dump", 0}; /*< Possible values for output-format. */
const char *cmdline_parser_output_format_values[] = {"hepmc2", "hepmc3", "hpe", "root", "treeroot", "treerootopal", "hpezeus", "dump", "dot", 0}; /*< Possible values for output-format. */
static char *
gengetopt_strdup (const char *s);
......
......@@ -35,10 +35,14 @@
#ifdef HEPMCCONVERT_EXTENSION_HEPEVTZEUS
#include "WriterHEPEVTZEUS.h"
#endif
#ifdef HEPMCCONVERT_EXTENSION_DOT
#include "WriterDOT.h"
#endif
#include "cmdline.h"
using namespace HepMC3;
enum formats {hepmc2, hepmc3, hpe ,root, treeroot ,treerootopal, hpezeus, lhef, dump};
enum formats {hepmc2, hepmc3, hpe ,root, treeroot ,treerootopal, hpezeus, lhef, dump, dot, none};
int main(int argc, char** argv)
{
gengetopt_args_info ai;
......@@ -60,6 +64,8 @@ int main(int argc, char** argv)
format_map.insert(std::pair<std::string,formats> ( "hpezeus", hpezeus ));
format_map.insert(std::pair<std::string,formats> ( "lhef", lhef ));
format_map.insert(std::pair<std::string,formats> ( "dump", dump ));
format_map.insert(std::pair<std::string,formats> ( "dot", dot ));
format_map.insert(std::pair<std::string,formats> ( "none", none ));
std::map<std::string, std::string> options;
for (size_t i=0; i<ai.extensions_given; i++)
{
......@@ -74,6 +80,7 @@ int main(int argc, char** argv)
long int last_event_number = ai.last_event_number_arg;
long int print_each_events_parsed = ai.print_every_events_parsed_arg;
Reader* input_file=0;
bool ignore_writer=false;
switch (format_map.at(std::string(ai.input_format_arg)))
{
case hepmc2:
......@@ -156,10 +163,24 @@ int main(int argc, char** argv)
#else
printf("Output format %s is not supported\n",ai.output_format_arg);
exit(2);
#endif
case dot:
#ifdef HEPMCCONVERT_EXTENSION_DOT
output_file=new WriterDOT(ai.inputs[1]);
if (options.find("Style")!=options.end()) ((WriterDOT*)(output_file))->set_style(std::atoi(options.at("Style").c_str()));
break;
#else
printf("Output format %s is not supported\n",ai.output_format_arg);
exit(2);
break;
#endif
case dump:
output_file=NULL;
break;
case none:
output_file=NULL;
ignore_writer=true;
break;
default:
printf("Output format %s is not known\n",ai.output_format_arg);
exit(2);
......@@ -177,6 +198,7 @@ int main(int argc, char** argv)
if (evt.event_number()>last_event_number) continue;
evt.set_run_info(input_file->run_info());
//Note the difference between ROOT and Ascii readers. The former read GenRunInfo before first event and the later at the same time as first event.
if (!ignore_writer)
if (output_file) output_file->write_event(evt);
else Print::content(evt);
evt.clear();
......
#ifndef HEPMC3_WRITERDOT_H
#define HEPMC3_WRITERDOT_H
///
/// @file WriterDOT.h
/// @brief Definition of class \b WriterDOT
///
/// @class HepMC3::WriterDOT
/// @brief GenEvent I/O output to dot files that should be processed by graphviz or other software
///
/// @ingroup Examples
///
#include <string>
#include <fstream>
#include "HepMC3/Writer.h"
#include "HepMC3/GenEvent.h"
#include "HepMC3/GenParticle.h"
#include "HepMC3/GenVertex.h"
#include "HepMC3/Data/GenEventData.h"
namespace HepMC3
{
class WriterDOT : public Writer
{
public:
/// @brief Constructor
/// @warning If file already exists, it will be cleared before writing
WriterDOT(const std::string &filename,shared_ptr<GenRunInfo> run = shared_ptr<GenRunInfo>());
/// @brief Constructor from ostream
WriterDOT(std::ostream& stream,shared_ptr<GenRunInfo> run = shared_ptr<GenRunInfo>());
/// @brief Write event to file
///
/// @param[in] evt Event to be serialized
void write_event(const GenEvent &evt);
/// @brief Return status of the stream
bool failed() {
return (bool)m_file.rdstate();
}
/// @brief Close file stream
void close();
/// @brief Close file stream
void set_style(const int& istyle) {
m_style=istyle;
};
private:
void allocate_buffer();
void flush();
void forced_flush();
std::ofstream m_file; //!< Output file
std::ostream* m_stream; //!< Output stream
int m_style; //!< style of dot file
char* m_buffer; //!< Stream buffer
char* m_cursor; //!< Cursor inside stream buffer
unsigned long m_buffer_size; //!< Buffer size
};
}
#endif
#include "WriterDOT.h"
namespace HepMC3
{
WriterDOT::WriterDOT(const std::string &filename,shared_ptr<GenRunInfo> run): m_file(filename),
m_stream(&m_file),
m_buffer(nullptr),
m_cursor(nullptr),
m_buffer_size( 256*1024 ),
m_style(0)
{
if ( !m_file.is_open() ) {
ERROR( "WriterDOT: could not open output file: "<<filename )
}
}
WriterDOT::WriterDOT(std::ostream &stream, shared_ptr<GenRunInfo> run)
: m_file(),
m_stream(&stream),
m_buffer(nullptr),
m_cursor(nullptr),
m_buffer_size( 256*1024 ),
m_style(0)
{}
void WriterDOT::close() {
std::ofstream* ofs = dynamic_cast<std::ofstream*>(m_stream);
if (ofs && !ofs->is_open()) return;
forced_flush();
if (ofs) ofs->close();
}
bool is_parton(const int& pd )
{
bool parton=false;
if (pd==81||pd==82||pd<25) parton=true;
if (
(pd/1000==1||pd/1000==2||pd/1000==3||pd/1000==4||pd/1000==5)
&&(pd%1000/100==1||pd%1000/100==2||pd%1000/100==3||pd%1000/100==4)
&&(pd%100==1||pd%100==3)
)
parton=true;
return parton;
}
void WriterDOT::write_event(const GenEvent &evt)
{
allocate_buffer();
if ( !m_buffer ) return;
flush();
m_cursor += sprintf(m_cursor, "digraph graphname%d {\n",evt.event_number());
m_cursor += sprintf(m_cursor, "v0[label=\"Machine\"];\n");
for(auto v: evt.vertices() ) {
if (m_style!=0)
{
if (m_style==1) //paint decay and fragmentation vertices in green
{
if (v->status()==2) m_cursor += sprintf(m_cursor, "node [color=\"green\"];\n");
else m_cursor += sprintf(m_cursor, "node [color=\"black\"];\n");
}
}
m_cursor += sprintf(m_cursor, "node [shape=ellipse];\n");
m_cursor += sprintf(m_cursor, "v%d[label=\"%d\"];\n", -v->id(),v->id());
flush();
}
for(auto p: evt.beams() ) {
if (!p->end_vertex()) continue;
m_cursor += sprintf(m_cursor, "node [shape=point];\n");
m_cursor += sprintf(m_cursor, "v0 -> v%d [label=\"%d(%d)\"];\n", -p->end_vertex()->id(),p->id(),p->pid());
}
for(auto v: evt.vertices() ) {
for(auto p: v->particles_out() ) {
{
if (m_style!=0)
{
if (m_style==1) //paint suspected partons and 81/82 in red
{
if (is_parton(std::abs(p->pid()))&&p->status()!=1) m_cursor += sprintf(m_cursor, "edge [color=\"red\"];\n");
else m_cursor +=sprintf(m_cursor, "edge [color=\"black\"];\n");
}
}
if (!p->end_vertex())
{
m_cursor += sprintf(m_cursor, "node [shape=point];\n");
m_cursor += sprintf(m_cursor, "v%d -> o%d [label=\"%d(%d)\"];\n", -v->id(),p->id(),p->id(),p->pid());
flush();
continue;
}
m_cursor += sprintf(m_cursor, "node [shape=ellipse];\n");
m_cursor += sprintf(m_cursor, "v%d -> v%d [label=\"%d(%d)\"];\n", -v->id(),-p->end_vertex()->id(),p->id(),p->pid());
flush();
}
}
}
m_cursor += sprintf(m_cursor, "labelloc=\"t\";\nlabel=\"Event %d; Vertices %lu; Particles %lu;\";\n", evt.event_number(), evt.vertices().size(), evt.particles().size());
m_cursor += sprintf(m_cursor,"}\n\n");
forced_flush();
}
void WriterDOT::allocate_buffer() {
if ( m_buffer ) return;
while( m_buffer==nullptr && m_buffer_size >= 256 ) {
try {
m_buffer = new char[ m_buffer_size ]();
} catch (const std::bad_alloc& e) {
delete[] m_buffer;
m_buffer_size /= 2;
WARNING( "WriterDOT::allocate_buffer: buffer size too large. Dividing by 2. New size: " << m_buffer_size )
}
}
if ( !m_buffer ) {
ERROR( "WriterDOT::allocate_buffer: could not allocate buffer!" )
return;
}
m_cursor = m_buffer;
}
inline void WriterDOT::flush() {
// The maximum size of single add to the buffer (other than by
// using WriterDOT::write) is 32 bytes. This is a safe value as
// we will not allow precision larger than 24 anyway
unsigned long length = m_cursor - m_buffer;
if ( m_buffer_size - length < 32 ) {
// m_file.write( m_buffer, length );
m_stream->write( m_buffer, length );
m_cursor = m_buffer;
}
}
inline void WriterDOT::forced_flush() {
// m_file.write( m_buffer, m_cursor-m_buffer );
m_stream->write( m_buffer, m_cursor - m_buffer );
m_cursor = m_buffer;
}
} // namespace HepMC3
......@@ -11,7 +11,7 @@ set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
configure_file(
${CMAKE_SOURCE_DIR}/examples/LHEFExample/LHEF_example_env.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/LHEF_example_env.sh.in
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/LHEF_example_env.sh
@ONLY
)
......@@ -21,4 +21,4 @@ ${CMAKE_SOURCE_DIR}/examples/LHEFExample/LHEF_example_env.sh.in
install(TARGETS LHEF_example_cat.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES LHEF_example.lhe LHEF_example_cmp.lhe DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES_MATCHING PATTERN "*env.sh")
FILES_MATCHING PATTERN "*env.sh*")
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/interfaces/pythia8/include
${PYTHIA8_INCLUDE_DIR})
if (USE_INSTALLED_HEPMC3)
#This version is for standalone compilation of examples.
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH})
find_package(Pythia8 QUIET)
if(PYTHIA8_FOUND)
include_directories(${PROJECT_SOURCE_DIR}/include ${HEPMC3_ROOT_DIR}/share/HepMC3/interfaces/pythia8/include ${PYTHIA8_INCLUDE_DIR})
add_executable(pythia8_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example.cc ${HEPMC3_ROOT_DIR}/share/HepMC3/interfaces/pythia8/src/Pythia8ToHepMC3.cc)
endif()
else()
#This version is for compilation during installation. Should be consistent with Pythia used in tests
set(PYTHIA8_ROOT_DIR "" CACHE PATH "Location of Pythia8 installation.")
find_package(Pythia8 QUIET)
if(PYTHIA8_FOUND)
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/interfaces/pythia8/include ${PYTHIA8_INCLUDE_DIR})
add_executable(pythia8_example.exe ${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example.cc ${PROJECT_SOURCE_DIR}/interfaces/pythia8/src/Pythia8ToHepMC3.cc)
endif()
endif()
if(PYTHIA8_FOUND)
target_link_libraries(pythia8_example.exe ${PYTHIA8_LIBRARIES} HepMC3)
set_target_properties(pythia8_example.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR})
......@@ -12,7 +28,7 @@ get_filename_component(PYTHIA8_LIB_DIR ${PYTHIA8_LIBRARY} PATH)
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${PYTHIA8_LIB_DIR}")
set(pythia8data "${PYTHIA8_XMLDOC_DIR}")
configure_file(${CMAKE_SOURCE_DIR}/examples/Pythia8Example/pythia8_example_env.sh.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pythia8_example_env.sh.in
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/pythia8_example_env.sh
@ONLY
)
......@@ -21,4 +37,9 @@ configure_file(${CMAKE_SOURCE_DIR}/examples/Pythia8Example/pythia8_example_env.s
install(TARGETS pythia8_example.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES pythia8_ee_to_Z_to_tautau.conf DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES_MATCHING PATTERN "*env.sh")
FILES_MATCHING PATTERN "*env.sh*")
else()
message(STATUS "Examples: Pythia8 package not found. Please check if PYTHIA8_ROOT_DIR is set properly.")
message(STATUS "pythia8_example disabled")
endif()
# - Locate pythia8 library
# Defines:
#
# PYTHIA8_FOUND
# PYTHIA8_VERSION
# PYTHIA8_INCLUDE_DIR
# PYTHIA8_XMLDOC_DIR
# PYTHIA8_INCLUDE_DIRS (not cached)
# PYTHIA8_LIBRARY
# PYTHIA8_hepmcinterface_LIBRARY
# PYTHIA8_lhapdfdummy_LIBRARY
# PYTHIA8_LIBRARIES (not cached) : includes 3 libraries above; not to be used if lhapdf is used
set(TEST_PYTHIA8_ROOT_DIR "" ${PYTHIA8_ROOT_DIR})
IF(TEST_PYTHIA8_ROOT_DIR STREQUAL "")
IF(DEFINED ENV{PYTHIA8_ROOT_DIR})
set(PYTHIA8_ROOT_DIR $ENV{PYTHIA8_ROOT_DIR})
else()
set(PYTHIA8_ROOT_DIR "/usr")
endif()
endif()
find_path(PYTHIA8_INCLUDE_DIR Pythia.h Pythia8/Pythia.h
HINTS ${PYTHIA8_ROOT_DIR}/include)
find_path(PYTHIA8_XMLDOC_DIR Version.xml
HINTS ${PYTHIA8_ROOT_DIR}/xmldoc ${PYTHIA8_ROOT_DIR}/share/Pythia8/xmldoc ${PYTHIA8_ROOT_DIR}/share/pythia8-data/xmldoc ${PYTHIA8_ROOT_DIR}/share/doc/packages/pythia/xmldoc )
if(PYTHIA8_INCLUDE_DIR AND PYTHIA8_XMLDOC_DIR)
file(READ ${PYTHIA8_XMLDOC_DIR}/Version.xml versionstr)
string(REGEX REPLACE ".*Pythia:versionNumber.*default.*[0-9][.]([0-9]+).*" "\\1" PYTHIA8_VERSION "${versionstr}")
find_library(PYTHIA8_LIBRARY NAMES pythia8 Pythia8
HINTS ${PYTHIA8_ROOT_DIR}/lib
${PYTHIA8_ROOT_DIR}/lib64)
find_library(PYTHIA8_lhapdfdummy_LIBRARY NAMES lhapdfdummy
HINTS ${PYTHIA8_ROOT_DIR}/lib
${PYTHIA8_ROOT_DIR}/lib64)
set(PYTHIA8_INCLUDE_DIRS ${PYTHIA8_INCLUDE_DIR} ${PYTHIA8_INCLUDE_DIR}/Pythia8 )
set(PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARY})
if(PYTHIA8_VERSION VERSION_LESS 200)
#Is this library needed?
#set(PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARY} ${PYTHIA8_lhapdfdummy_LIBRARY})
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set PYTHIA8_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pythia8 DEFAULT_MSG PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARIES PYTHIA8_XMLDOC_DIR)
mark_as_advanced(PYTHIA8_FOUND PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARY PYTHIA8_LIBRARIES PYTHIA8_XMLDOC_DIR)
......@@ -15,7 +15,7 @@ set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${ROOT_LIBRARY_DIR}")
configure_file(
${CMAKE_SOURCE_DIR}/examples/RootIOExample/rootIO_example_env.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/rootIO_example_env.sh.in
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/rootIO_example_env.sh
@ONLY
)
......@@ -24,4 +24,4 @@ ${CMAKE_SOURCE_DIR}/examples/RootIOExample/rootIO_example_env.sh.in
install(TARGETS rootIO_example_write.exe rootIO_example_read.exe DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES example.hepmc3 DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/ DESTINATION ${CMAKE_INSTALL_BINDIR}
FILES_MATCHING PATTERN "*env.sh")
FILES_MATCHING PATTERN "*env.sh*")
This diff is collapsed.
......@@ -33,14 +33,14 @@ set(bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:${ROOT_LIBRARY_DIR}")
configure_file(
${CMAKE_SOURCE_DIR}/examples/RootIOExample2/class_example_env.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/class_example_env.sh.in
${PROJECT_BINARY_DIR}/outputs/${CMAKE_INSTALL_BINDIR}/class_example_env.sh
@ONLY
)
# installs