Index: tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_namespaces.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_namespaces.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_namespaces.m4 (revision 921) @@ -0,0 +1,22 @@ +dnl @synopsis AC_CXX_NAMESPACES +dnl +dnl If the compiler can prevent names clashes using namespaces, define +dnl HAVE_NAMESPACES. +dnl +dnl @version $Id: ac_cxx_namespaces.m4,v 1.1.1.1 2003/03/19 02:40:00 mes5k Exp $ +dnl @author Luc Maisonobe +dnl +AC_DEFUN([AC_CXX_NAMESPACES], +[AC_CACHE_CHECK(whether the compiler implements namespaces, +ac_cv_cxx_namespaces, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], + [using namespace Outer::Inner; return i;], + ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_namespaces" = yes; then + AC_DEFINE(HAVE_NAMESPACES,1,[define to 1 if the compiler implements namespaces]) +fi +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/ax_check_zlib.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/ax_check_zlib.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/ax_check_zlib.m4 (revision 921) @@ -0,0 +1,142 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_zlib.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_ZLIB([action-if-found], [action-if-not-found]) +# +# DESCRIPTION +# +# This macro searches for an installed zlib library. If nothing was +# specified when calling configure, it searches first in /usr/local and +# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified, +# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If +# --without-zlib is specified, the library is not searched at all. +# +# If either the header file (zlib.h) or the library (libz) is not found, +# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is +# not specified, the configuration exits on error, asking for a valid zlib +# installation directory or --without-zlib. +# +# If both header file and library are found, shell commands +# 'action-if-found' is run. If 'action-if-found' is not specified, the +# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends +# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls +# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition +# for this symbol in a config.h file. Sample usage in a C/C++ source is as +# follows: +# +# #ifdef HAVE_LIBZ +# #include <zlib.h> +# #endif /* HAVE_LIBZ */ +# +# LICENSE +# +# Copyright (c) 2008 Loic Dachary <loic@senga.org> +# Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see <https://www.gnu.org/licenses/>. +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 15 + +AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB]) +AC_DEFUN([AX_CHECK_ZLIB], +# +# Handle user hints +# +[AC_MSG_CHECKING(if zlib is wanted) +zlib_places="/usr/local /usr /opt/local /sw" +AC_ARG_WITH([zlib], +[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to + /usr/local or /usr if not found in /usr/local@:>@ + --without-zlib to disable zlib usage completely], +[if test "$withval" != no ; then + AC_MSG_RESULT(yes) + if test -d "$withval" + then + zlib_places="$withval $zlib_places" + else + AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) + fi +else + zlib_places= + AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(yes)]) + +# +# Locate zlib, if wanted +# +if test -n "${zlib_places}" +then + # check the user supplied or any other more or less 'standard' place: + # Most UNIX systems : /usr/local and /usr + # MacPorts / Fink on OSX : /opt/local respectively /sw + for ZLIB_HOME in ${zlib_places} ; do + if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi + ZLIB_HOME="" + done + + ZLIB_OLD_LDFLAGS=$LDFLAGS + ZLIB_OLD_CPPFLAGS=$CPPFLAGS + if test -n "${ZLIB_HOME}"; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + fi + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no]) + AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) + AC_LANG_RESTORE + if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes" + then + # + # If both library and header were found, action-if-found + # + m4_ifblank([$1],[ + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + LIBS="-lz $LIBS" + AC_DEFINE([HAVE_LIBZ], [1], + [Define to 1 if you have `z' library (-lz)]) + ],[ + # Restore variables + LDFLAGS="$ZLIB_OLD_LDFLAGS" + CPPFLAGS="$ZLIB_OLD_CPPFLAGS" + $1 + ]) + else + # + # If either header or library was not found, action-if-not-found + # + m4_default([$2],[ + AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib]) + ]) + fi +fi +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/lcg.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/lcg.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/lcg.m4 (revision 921) @@ -0,0 +1,65 @@ +#AC_SEARCH_LCG(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_LCG],[ + + HAVE_LCG=no + + if test "x$LCG_TAG" != "xno" ; then + lcg_string=$LCG_TAG + else + + if test -d /afs/cern.ch/sw/lcg/external/ ; then + + if test -e "/etc/redhat-release"; then + slcstring=`cat /etc/redhat-release | grep "Scientific Linux"` + + if test "x$slcstring" != "x"; then + slcVersion=`cat /etc/redhat-release | cut -d " " -f 6 | cut -d . -f 1` + dist=slc${slcVersion} + + machine=`uname -m` + + if test -z "$CXX"; then + echo "running ac_path_prog for CXX" + AC_PATH_PROG(CXX, [g++]) + fi + + cxx_path=`which $CXX` + + if test -x "$cxx_path"; then + gccVersion=`$cxx_path --version | head -1 | cut -d " " -f 3` + major=`echo $gccVersion | cut -d . -f 1` + minor=`echo $gccVersion | cut -d . -f 2` + gccCode=gcc${major}${minor} + fi + + # Many packages (e.g. Pythia8!) not built for gcc 41, but 43 is "ok" + if test "x${dist}-${gccCode}" == "xslc5-gcc41" ; then + gccCode="gcc43" + fi + + # And in SLC6 we want to use gcc 46 + if test "x${dist}-${gccCode}" == "xslc6-gcc44"; then + gccCode="gcc46" + fi + + lcg_string=${machine}-${dist}-${gccCode}-opt + + fi + fi + fi + fi + + if test "x$lcg_string" != "x" ; then + HAVE_LCG=yes + LCG_TAG=$lcg_string + export LCG_TAG + AC_SUBST([LCG_TAG]) + AC_MSG_NOTICE([Found lcg tag = $LCG_TAG]) + else + AC_MSG_NOTICE([Cannot interpret lcg tag - not searching AFS paths!]) + fi + + export HAVE_LCG + AC_SUBST([HAVE_LCG]) + +]) \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_sstream.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_sstream.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_sstream.m4 (revision 921) @@ -0,0 +1,25 @@ +dnl @synopsis AC_CXX_HAVE_SSTREAM +dnl +dnl If the C++ library has a working stringstream, define HAVE_SSTREAM. +dnl +dnl @author Ben Stanley +dnl @version $Id: ac_cxx_have_sstream.m4,v 1.2 2006/02/22 02:10:28 zeekec Exp $ +dnl +AC_DEFUN([AC_CXX_HAVE_SSTREAM], +[AC_REQUIRE([AC_CXX_NAMESPACES]) +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +AC_CHECK_HEADERS(sstream) +AC_CACHE_CHECK([whether the STL defines stringstream], +[ac_cv_cxx_have_sstream], +[AC_TRY_COMPILE([#include <sstream> +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[stringstream message; message << "Hello"; return 0;], + ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no) +]) +if test "$ac_cv_cxx_have_sstream" = yes; then + AC_DEFINE(HAVE_SSTREAM,1,[define if the compiler has stringstream]) +fi +AC_LANG_RESTORE +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_strstream.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_strstream.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/ac_cxx_have_strstream.m4 (revision 921) @@ -0,0 +1,28 @@ +dnl @synopsis AC_CXX_HAVE_STRSTREAM +dnl +dnl If the C++ library has a working strstream, define HAVE_CLASS_STRSTREAM. +dnl +dnl Adapted from ac_cxx_have_sstream.m4 by Steve Robbins +dnl +AC_DEFUN([AC_CXX_HAVE_STRSTREAM], +[AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_CHECK_HEADERS(strstream) + AC_CACHE_CHECK([whether the STL defines strstream], +[ac_cv_cxx_have_class_strstream], +[AC_TRY_COMPILE([#if HAVE_STRSTREAM +# include <strstream> +#else +# include <strstream.h> +#endif +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[ostrstream message; message << "Hello"; return 0;], + ac_cv_cxx_have_class_strstream=yes, ac_cv_cxx_have_class_strstream=no) +]) +if test "$ac_cv_cxx_have_class_strstream" = yes; then + AC_DEFINE(HAVE_CLASS_STRSTREAM,1,[define if the library defines strstream]) +fi +AC_LANG_RESTORE +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/hepmc.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/hepmc.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/hepmc.m4 (revision 921) @@ -0,0 +1,88 @@ +#AC_SEARCH_HEPMC(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_HEPMC],[ + + afs_base_path="/afs/cern.ch/sw/lcg/external/HepMC/2.06.05/${LCG_TAG}" + + if test x$with_HepMC != x && test x$with_HepMC != xyes ; then + AC_MSG_NOTICE([Adding $with_HepMC to search path for HepMC]) + if test -d $with_HepMC/include/HepMC && test -d $with_HepMC/lib ; then + found_HepMC=yes + HepMC_base_path=`echo ${with_HepMC%/}` + HepMC_include=$with_HepMC/include/ + HepMC_lib=$with_HepMC/lib + else + found_HepMC=no + fi + fi + +# If we failed to find it in the specified path then check some ~standard locations +# Add some default afs search paths here if LCG_TAG is defined +# Todo: maybe work out the most recent version of HepMC more intelligently. + + if test x$found_HepMC != xyes ; then + + searchPaths="/usr /usr/local /opt /opt/local" + + if test "x$HAVE_LCG" == "xyes" ; then + searchPaths="$searchPaths $afs_base_path" + fi + + for ac_hepmc_path_tmp in $searchPaths ; do + + AC_MSG_NOTICE([Testing $ac_hepmc_path_tmp for HepMC...]) + + if test -d $ac_hepmc_path_tmp/include/HepMC && test -d $ac_hepmc_path_tmp/lib ; then + + AC_MSG_NOTICE([...found]) + + found_HepMC=yes + HepMC_base_path=$ac_hepmc_path_tmp + HepMC_include=$ac_hepmc_path_tmp/include/ + HepMC_lib=$ac_hepmc_path_tmp/lib + fi + done + fi + +# final check that the headers and libraries are actually there + if test x$found_HepMC = xyes ; then + if test -f $HepMC_include/HepMC/GenEvent.h && test -f $HepMC_lib/libHepMC.$LIB_SUFFIX ; then + HEPMC_LDFLAGS="-L$HepMC_lib -lHepMC" + HEPMC_CPPFLAGS="-I$HepMC_include" + HEPMC_LIBDIR="$HepMC_lib" + + if test -f $HepMC_include/HepMC/Units.h ; then + HEPMC_CPPFLAGS="$HEPMC_CPPFLAGS -DHEPMC_HAS_UNITS" + fi + + else + found_HepMC=no + HAVE_LCG=no + fi + fi + + if test x$found_HepMC = xyes ; then + + if test "x$HepMC_base_path" != "x$afs_base_path"; then + + if test "x$HAVE_LCG" == "xyes"; then + AC_MSG_WARN([Use of LCG installations disabled: HepMC version found does not match]) + fi + + HAVE_LCG=no + fi + + export HEPMC_LDFLAGS + export HEPMC_CPPFLAGS + export HEPMC_LIBDIR + AC_SUBST([HEPMC_LDFLAGS]) + AC_SUBST([HEPMC_CPPFLAGS]) + AC_SUBST([HEPMC_LIBDIR]) + AC_MSG_NOTICE([Found HepMC package]) + AC_MSG_NOTICE([HEPMC_LDFLAGS = $HEPMC_LDFLAGS]) + AC_MSG_NOTICE([HEPMC_CPPFLAGS = $HEPMC_CPPFLAGS]) + $1 + else + AC_MSG_NOTICE([Could not find HepMC package]) + $2 + fi +]) \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/m4/photos.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/photos.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/photos.m4 (revision 921) @@ -0,0 +1,87 @@ +#AC_SEARCH_PHOTOS(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_PHOTOS],[ + +if test x$with_photos != x && test x$with_photos != xyes ; then + AC_MSG_NOTICE([Adding $with_photos to search path for Photos++]) + if test -d $with_photos/include/ && test -d $with_photos/lib ; then + found_photos=yes + photos_include=$with_photos/include/ + photos_lib=$with_photos/lib + else + found_photos=no + fi +fi + +# If we failed to find it in the specified path then check some ~standard locations +# Add some default afs search paths here if LCG_TAG is defined +# Take the most recent version of Photos, if possible + +if test x$found_photos != xyes ; then + + searchPaths="/usr /usr/local /opt /opt/local" + + if test "x$HAVE_LCG" == "xyes" ; then + + afs_base_path="/afs/cern.ch/sw/lcg/external/MCGenerators_lcgcmt64/photos++/" + afs_subdirs=`ls $afs_base_path` + photos_version=`for dir in $afs_subdirs; do echo $dir; done | sort -r | head -n 1` + + searchPaths="$searchPaths ${afs_base_path}${photos_version}/${LCG_TAG}" + fi + + for ac_photos_path_tmp in $searchPaths ; do + + AC_MSG_NOTICE([Testing $ac_photos_path_tmp for Photos++...]) + + if test -d $ac_photos_path_tmp/include && test -d $ac_photos_path_tmp/lib && test x$found_photos != xyes ; then + + photos_include=$ac_photos_path_tmp/include/ + photos_lib=$ac_photos_path_tmp/lib + + if test -f $photos_include/Photos/Photos.h ; then + AC_MSG_NOTICE([...found]) + found_photos=yes + fi + + fi + done +fi + +# final check that the headers and libraries are actually there +if test x$found_photos = xyes ; then + if test -f $photos_include/Photos/Photos.h && test -f $photos_lib/libPhotosCxxInterface.$LIB_SUFFIX && test -f $photos_lib/libPhotosFortran.$LIB_SUFFIX; then + PHOTOS_LDFLAGS="-L$photos_lib -lPhotosCxxInterface -lPhotosFortran" + PHOTOS_CPPFLAGS="-I$photos_include" + PHOTOS_LIBDIR="$photos_lib" + + has_namespace=`grep "namespace Photospp" $photos_include/Photos/Photos.h | head -n 1` + + if test "x$has_namespace" != "x" ; then + PHOTOS_CPPFLAGS="$PHOTOS_CPPFLAGS -DPHOTOS_HAS_NAMESPACE" + fi + + else + AC_MSG_NOTICE([Tried $photos_include/Photos/Photos.h , $photos_lib/libPhotosCxxInterface.$LIB_SUFFIX and $photos_lib/libPhotosFortran.$LIB_SUFFIX]) + found_photos=no + fi +fi + +if test x$found_photos = xyes ; then + + export PHOTOS_LDFLAGS + export PHOTOS_CPPFLAGS + export PHOTOS_LIBDIR + AC_SUBST([PHOTOS_LDFLAGS]) + AC_SUBST([PHOTOS_CPPFLAGS]) + AC_SUBST([PHOTOS_LIBDIR]) + AC_MSG_NOTICE([Found Photos++ libraries and headers]) + AC_MSG_NOTICE([PHOTOS_LDFLAGS = $PHOTOS_LDFLAGS]) + AC_MSG_NOTICE([PHOTOS_CPPFLAGS = $PHOTOS_CPPFLAGS]) + $1 +else + AC_MSG_NOTICE([Could not find Photos++ libraries and headers]) + $2 +fi + +]) + Index: tags/Sacrifice-1.1.1/Sacrifice/m4/dynamic_libs.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/dynamic_libs.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/dynamic_libs.m4 (revision 921) @@ -0,0 +1,21 @@ +#AC_DEFINE_DYNAMIC_LIBS() +#Defines LIB_SUFFIX to be either so or dylib for linux or mac +#Also sets LIBPATHVARNAME to either LD_LIBRARY_PATH or DYLD_LIBRARY_PATH +AC_DEFUN([AC_DEFINE_DYNAMIC_LIBS],[ + + LIB_SUFFIX="so" + LIBPATHVARNAME="LD_LIBRARY_PATH" + + AC_CHECK_TOOL(SWVERS, sw_vers) + if test x$SWVERS != x; then + PROD_NAME=$($SWVERS -productName | cut -f 2 -d:) + fi + + if test "$PROD_NAME" = "Mac OS X"; then + LIB_SUFFIX="dylib" + LIBPATHVARNAME="DYLD_LIBRARY_PATH" + fi + + AC_SUBST(LIB_SUFFIX) + AC_SUBST(LIBPATHVARNAME) +]) \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/m4/lhapdf.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/lhapdf.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/lhapdf.m4 (revision 921) @@ -0,0 +1,62 @@ +#AC_SEARCH_LHAPDF(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_LHAPDF], [ +LHAPDF_CONFIG_PATH=$PATH + +if test x$with_LHAPDF != x ; then + AC_MSG_NOTICE([Adding $with_LHAPDF to lhapdf-config search path]) + LHAPDF_CONFIG_PATH=$with_LHAPDF/bin:$with_LHAPDF:$LHAPDF_CONFIG_PATH +fi + +AC_MSG_NOTICE([lhapdf-config search path is $LHAPDF_CONFIG_PATH]) + +AC_PATH_PROG(LHAPDF_CONFIG, [lhapdf-config], [no], [$LHAPDF_CONFIG_PATH]) + +# if failed to find lhapdf-config in the default $PATH, check some other default areas + +if test "x$LHAPDF_CONFIG" == "xno" ; then + + searchPaths="/usr/bin /usr/local/bin /opt/bin /opt/local/bin" + + if test "x$HAVE_LCG" == "xyes" ; then + afs_base_path="/afs/cern.ch/sw/lcg/external/MCGenerators_lcgcmt64/lhapdf/" + afs_subdirs=`ls $afs_base_path` + lhapdf_version=`for dir in $afs_subdirs; do echo $dir; done | sort -r | head -n 1` + searchPaths="$searchPaths ${afs_base_path}${lhapdf_version}/${LCG_TAG}/bin/" + fi + + for ac_lhapdf_path_tmp in $searchPaths ; do + AC_MSG_NOTICE([Testing $ac_lhapdf_path_tmp for lhapdf-config...]) + if test -x ${ac_lhapdf_path_tmp}lhapdf-config && test "x$LHAPDF_CONFIG" == "xno"; then + AC_MSG_NOTICE([...found]) + LHAPDF_CONFIG=${ac_lhapdf_path_tmp}lhapdf-config + fi + done + +fi + +if test x$LHAPDF_CONFIG != xno ; then + + AC_MSG_NOTICE([Found lhapdf-config]) + LHAPDF_CPPFLAGS="`$LHAPDF_CONFIG --cppflags`" + LHAPDF_LDFLAGS="`$LHAPDF_CONFIG --ldflags`" + LHAPDF_LIBDIR="`$LHAPDF_CONFIG --libdir`" + LHAPDF_LHAPATH="`$LHAPDF_CONFIG --pdfsets-path`" + + export LHAPDF_CPPFLAGS + export LHAPDF_LDFLAGS + export LHAPDF_LIBDIR + export LHAPDF_LHAPATH + AC_SUBST([LHAPDF_CPPFLAGS]) + AC_SUBST([LHAPDF_LDFLAGS]) + AC_SUBST([LHAPDF_LIBDIR]) + AC_SUBST([LHAPDF_LHAPATH]) + + AC_MSG_NOTICE([LHAPDF_CPPFLAGS = $LHAPDF_CPPFLAGS]) + AC_MSG_NOTICE([LHAPDF_LDFLAGS = $LHAPDF_LDFLAGS]) + + $1 +else + AC_MSG_NOTICE([LHAPDF not found!!]) + $2 +fi +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/pythia.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/pythia.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/pythia.m4 (revision 921) @@ -0,0 +1,137 @@ +#AC_SEARCH_PYTHIA(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_PYTHIA],[ + +if test x$with_pythia != x && test x$with_pythia != xyes ; then + AC_MSG_NOTICE([Adding $with_pythia to search path for Pythia]) + if test -d $with_pythia/include/ && test -d $with_pythia/lib ; then + found_pythia=yes + pythia_base=$with_pythia + pythia_include=$with_pythia/include/ + pythia_lib=$with_pythia/lib + pythia_data=$with_pythia/xmldoc + else + found_pythia=no + fi +fi + +# If we failed to find it in the specified path then check some ~standard locations +# Add some default afs search paths here if LCG_TAG is defined +# If no PYTHIA_VERSION is defined then try to use the most recent + +if test x$found_pythia != xyes ; then + + searchPaths="/usr /usr/local /opt /opt/local" + + if test "x$HAVE_LCG" == "xyes" ; then + + afs_base_path="/afs/cern.ch/sw/lcg/external/MCGenerators_lcgcmt64/pythia8/" + if test "x$PYTHIA_VERSION" == "xno" ; then + afs_subdirs=`ls $afs_base_path` + PYTHIA_VERSION=`for dir in $afs_subdirs; do echo $dir; done | sort -r | head -n 1` + fi + + AC_MSG_NOTICE([Testing for Pythia version $PYTHIA_VERSION in LCG AFS area]) + searchPaths="$searchPaths $afs_base_path/$PYTHIA_VERSION/${LCG_TAG}" + fi + + for ac_pythia_path_tmp in $searchPaths ; do + + AC_MSG_NOTICE([Testing $ac_pythia_path_tmp for Pythia 8...]) + + if test -d $ac_pythia_path_tmp/include && test -d $ac_pythia_path_tmp/lib && test -d $ac_pythia_path_tmp/xmldoc && test x$found_pythia != xyes; then + + AC_MSG_NOTICE([...found]) + + found_pythia=yes + pythia_base=$ac_pythia_path_tmp + pythia_include=$ac_pythia_path_tmp/include/ + pythia_lib=$ac_pythia_path_tmp/lib + pythia_data=$ac_pythia_path_tmp/xmldoc + fi + done +fi + +if test x$found_pythia = xno ; then + AC_MSG_ERROR([Could not find Pythia 8 libraries]) +fi + +# check for Pythia version > 8.180 + +if test -d $pythia_include/Pythia8Plugins ; then + pythiaversion="8200" + test_include="$pythia_include/Pythia8" + hepmclib="no" + pythia_data=$pythia_base/share/Pythia8/xmldoc +elif test -d $pythia_include/Pythia8 ; then + pythiaversion="8180" + test_include="$pythia_include/Pythia8" + hepmclib="pythia8tohepmc" +else + pythiaversion="8170" + test_include="$pythia_include" + hepmclib="hepmcinterface" +fi + +# final check that the headers and libraries are actually there +if test x$found_pythia = xyes ; then + if test -f $test_include/Pythia.h && test -f $pythia_lib/libpythia8.$LIB_SUFFIX && test -f $pythia_data/ParticleData.xml; then + PYTHIA_LIBDIR="$pythia_lib" + PYTHIA_LDFLAGS="-L$pythia_lib -lpythia8" + PYTHIA_CPPFLAGS="-I$pythia_include" + if test "x$pythiaversion" == "x8170" ; then + PYTHIA_CPPFLAGS="$PYTHIA_CPPFLAGS -DPYTHIA8176" + elif test "x$pythiaversion" == "x8180" ; then + PYTHIA_CPPFLAGS="$PYTHIA_CPPFLAGS -DPYTHIA8180" + else + PYTHIA_CPPFLAGS="$PYTHIA_CPPFLAGS -DPYTHIA8200" + fi + PYTHIA_DATA="$pythia_data" + + if test x$enable_HepMC = xyes && test x$hepmclib != xno ; then + if test -f $pythia_lib/lib$hepmclib.$LIB_SUFFIX ; then + PYTHIA_LDFLAGS="$PYTHIA_LDFLAGS -l$hepmclib" + else + AC_MSG_NOTICE([HepMC requested, but Pythia 8 interface library libhepmcinterface not found!]) + found_pythia=no + fi + fi + + if test x$enable_LHAPDF != xyes && test x$pythiaversion != x8200 ; then + if test -f $pythia_lib/liblhapdfdummy.$LIB_SUFFIX ; then + PYTHIA_LDFLAGS="$PYTHIA_LDFLAGS -llhapdfdummy" + else + AC_MSG_NOTICE([LHAPDF not linked, but dummy Pythia 8 LHAPDf library not found!]) + found_pythia=no + fi + fi + + else + found_pythia=no + fi +fi + +if test x$found_pythia = xyes ; then + + export PYTHIA_LDFLAGS + export PYTHIA_CPPFLAGS + export PYTHIA_DATA + export PYTHIA_LIBDIR + AC_SUBST([PYTHIA_LDFLAGS]) + AC_SUBST([PYTHIA_CPPFLAGS]) + AC_SUBST([PYTHIA_DATA]) + AC_SUBST([PYTHIA_LIBDIR]) + AC_MSG_NOTICE([Found Pythia 8 libraries and headers]) + AC_MSG_NOTICE([PYTHIA_LDFLAGS = $PYTHIA_LDFLAGS]) + AC_MSG_NOTICE([PYTHIA_CPPFLAGS = $PYTHIA_CPPFLAGS]) + AC_MSG_NOTICE([PYTHIA_DATA = $PYTHIA_DATA]) + $1 +else + AC_MSG_NOTICE([Could not find complete set of Pythia 8 libraries and headers]) + $2 +fi + +]) + + + + Index: tags/Sacrifice-1.1.1/Sacrifice/m4/get_mcutils.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/get_mcutils.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/get_mcutils.m4 (revision 921) @@ -0,0 +1,34 @@ +#AC_GET_MCUTILS(actionIfSuccess, actionIfFail) +AC_DEFUN([AC_GET_MCUTILS],[ + +if test ! -f include/MCUtils/MCUtils.h ; then + mkdir tmp + curl https://bitbucket.org/andybuckley/mcutils/get/mcutils-1.3.2.tar.gz > tmp/mcutils-1.3.2.tar.gz + tar -zxvf tmp/mcutils-1.3.2.tar.gz -C tmp/ + cp -r tmp/andybuckley-mcutils-c5d9a7cfd128/include/MCUtils include + rm -r tmp +fi + +if test -f include/MCUtils/MCUtils.h ; then + $1 +else + $2 +fi + +if test ! -f include/HEPUtils/Vectors.h ; then + mkdir tmp + curl https://bitbucket.org/andybuckley/heputils/get/heputils-1.3.0.tar.gz > tmp/heputils.tar.gz + tar -zxvf tmp/heputils.tar.gz -C tmp/ + cp -r tmp/andybuckley-heputils-301e1b37bd2f/include/HEPUtils include + rm -r tmp +fi + +if test -f include/HEPUtils/Vectors.h ; then + $1 +else + $2 +fi + + + +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/ax_cxx_compile_stdcxx_11.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/ax_cxx_compile_stdcxx_11.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/ax_cxx_compile_stdcxx_11.m4 (revision 921) @@ -0,0 +1,142 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++11 +# standard; if necessary, add switches to CXXFLAGS to enable support. +# +# The first argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The second argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline C++11 support is required and that the macro +# should error out if no mode with that support is found. If specified +# 'optional', then configuration proceeds regardless, after defining +# HAVE_CXX11 if and only if a supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> +# Copyright (c) 2012 Zack Weinberg <zackw@panix.com> +# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> +# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 4 + +m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[ + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + struct Base { + virtual void f() {} + }; + struct Child : public Base { + virtual void f() override {} + }; + + typedef check<check<bool>> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check<int> check_type; + check_type c; + check_type&& cr = static_cast<check_type&&>(c); + + auto d = a; + auto l = [](){}; +]]) + +AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl + m4_if([$1], [], [], + [$1], [ext], [], + [$1], [noext], [], + [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl + m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], + [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], + [$2], [optional], [ax_cxx_compile_cxx11_required=false], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + AC_CACHE_CHECK(whether $CXX supports C++11 features by default, + ax_cv_cxx_compile_cxx11, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [ax_cv_cxx_compile_cxx11=yes], + [ax_cv_cxx_compile_cxx11=no])]) + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + m4_if([$1], [noext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=gnu++11 -std=gnu++0x; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + + m4_if([$1], [ext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=c++11 -std=c++0x; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) + fi + else + if test x$ac_success = xno; then + HAVE_CXX11=0 + AC_MSG_NOTICE([No compiler with C++11 support was found]) + else + HAVE_CXX11=1 + AC_DEFINE(HAVE_CXX11,1, + [define if the compiler supports basic C++11 syntax]) + fi + + AC_SUBST(HAVE_CXX11) + fi +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4/mcutils.m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4/mcutils.m4 (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/m4/mcutils.m4 (revision 921) @@ -0,0 +1,43 @@ +#AC_SEARCH_MCUTILS(actionIfFound, actionIfNotFound) +AC_DEFUN([AC_SEARCH_MCUTILS], [ + +if test x$with_MCUtils != x && test x$with_MCUtils != xyes ; then + AC_MSG_NOTICE([Adding $with_MCUtils to search path for MCUtils]) + if test -d $with_MCUtils/include/MCUtils ; then + found_mcutils=yes + mcutils_include=$with_MCUtils/include + else + found_mcutils=no + fi + +else + toplevel=`pwd` + mcutils_include=$toplevel/include/ + found_mcutils=yes +fi + + +# final check that the headers and libraries are actually there + +if test x$found_mcutils = xyes ; then + if test -f $mcutils_include/MCUtils/HepMCUtils.h ; then + MCUTILS_CPPFLAGS="-I$mcutils_include" + + else + found_mcutils=no + fi +fi + +if test x$found_mcutils = xyes ; then + + export MCUTILS_CPPFLAGS + AC_SUBST([MCUTILS_CPPFLAGS]) + AC_MSG_NOTICE([Found MCUtils header package]) + AC_MSG_NOTICE([MCUTILS_CPPFLAGS = $MCUTILS_CPPFLAGS]) + $1 +else + AC_MSG_NOTICE([Could not find MCUtils headers]) + $2 +fi + +]) Index: tags/Sacrifice-1.1.1/Sacrifice/m4 =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/m4 (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/m4 (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/m4 ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,7 ## +*~ +._* +libtool.m4 +lt~obsolete.m4 +ltsugar.m4 +ltversion.m4 +ltoptions.m4 Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/JetMatchingMadGraphHook.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/JetMatchingMadGraphHook.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/JetMatchingMadGraphHook.cxx (revision 921) @@ -0,0 +1,4 @@ +#include "Sacrifice/UserHooksFactory.hh" +#include "Pythia8Plugins/JetMatching.h" + +Sacrifice::UserHooksFactory::Creator<Pythia8::JetMatchingMadgraph> JetMatchingMadGraphCreator("JetMatchingMadgraph"); Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/EnhanceMPI.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/EnhanceMPI.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/EnhanceMPI.cxx (revision 921) @@ -0,0 +1,98 @@ +#include "UserHookUtils.hh" +#include "Sacrifice/UserHooksFactory.hh" +#include <stdexcept> +#include <iostream> + +namespace Pythia8{ + class EnhanceMPI; +} + +Sacrifice::UserHooksFactory::Creator<Pythia8::EnhanceMPI> EnhanceMPICreator("EnhanceMPI"); + +namespace Pythia8{ + + class EnhanceMPI : public UserHooks{ + + public: + + EnhanceMPI(): m_pTCut(10.), m_nMPIVeto(3){ + + std::cout<<"**********************************************************"<<std::endl; + std::cout<<"* *"<<std::endl; + std::cout<<"* Enhancing MPI emissions with UserHook! *"<<std::endl; + std::cout<<"* *"<<std::endl; + std::cout<<"**********************************************************"<<std::endl; + + } + + ~EnhanceMPI(){} + + bool doVetoMPIStep(int nMPI, const Event &event){ + + // MPI 1 is the hard process. We do not veto that! + if(nMPI < 2){ + m_passedEvent = false; + return false; + } + + if(m_passedEvent) return false; + + // start at the end of the event record and work back + // This is prior to showering, so there should be at most 2 new MPI emissions + // event[0] is documentation, so stop before that. + size_t nEmissions=0; + for(int ii=event.size()-1; ii > 0 && nEmissions != 2; --ii){ + if(event[ii].status() != 33) continue; + if(event[ii].pT() > m_pTCut){ + m_passedEvent = true; + return false; + } + + ++nEmissions; + } + + if(nMPI == m_nMPIVeto && !m_passedEvent){ +// std::cout<<"Vetoing event on too-little MPI"<<std::endl; + return true; + } + + return false; + } + + bool doVetoPartonLevel(const Event &event){ + if(m_passedEvent) return false; + + return true; + } + + /// Switch on calling of doVetoMPIStep + bool canVetoMPIStep(){return true;} + /// Call doVetoMIStep three times + /// First is the hard process + /// second is first MPI emission + /// *or* + /// the second part of a double diffractive event + /// *or* + /// the second hard process if there is on. + /// Therefore check up to 3 + int numberVetoMPIStep(){return m_nMPIVeto;} + /// Switch on veto of ISR + bool canVetoISREmission(){return false;} + /// Switch off veto of FSR + bool canVetoFSREmission(){return false;} + /// Check the event after the generation of the parton level but before hadronisation + bool canVetoPartonLevel(){return true;} + + private: + + double m_pTCut; + + bool m_passedEvent; + + int m_nMPIVeto; + + }; + + + +} Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/Makefile.am (revision 921) @@ -0,0 +1,11 @@ +lib_LTLIBRARIES = SacrificePlugin.la + +SacrificePlugin_la_SOURCES = main31.cxx \ + JetMatchingMadGraphHook.cxx \ + EnhanceMPI.cxx \ + SuppressMPI.cxx + +nobase_pkginclude_HEADERS = UserHookUtils.hh + +SacrificePlugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHIA_CPPFLAGS) +SacrificePlugin_la_LDFLAGS = $(AM_LDFLAGS) -module --avoid-version Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/main31.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/main31.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/main31.cxx (revision 921) @@ -0,0 +1,4 @@ +#include "Sacrifice/UserHooksFactory.hh" +#include "Pythia8Plugins/PowhegHooks.h" + +Sacrifice::UserHooksFactory::Creator<Pythia8::PowhegHooks> main31Creator("PowhegMain31"); Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/SuppressMPI.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/SuppressMPI.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/SuppressMPI.cxx (revision 921) @@ -0,0 +1,78 @@ +#include "UserHookUtils.hh" +#include "Sacrifice/UserHooksFactory.hh" +#include <stdexcept> +#include <iostream> + +namespace Pythia8{ + class SuppressMPI; +} + +Sacrifice::UserHooksFactory::Creator<Pythia8::SuppressMPI> SuppressMPICreator("SuppressMPI"); + +namespace Pythia8{ + + class SuppressMPI : public UserHooks{ + + public: + + SuppressMPI(): m_pTCut(10.), m_nMPIVeto(3){ + + std::cout<<"************************************************************"<<std::endl; + std::cout<<"* *"<<std::endl; + std::cout<<"* Suppressing MPI emissions with UserHook! *"<<std::endl; + std::cout<<"* *"<<std::endl; + std::cout<<"************************************************************"<<std::endl; + + } + + ~SuppressMPI(){} + + bool doVetoMPIStep(int nMPI, const Event &event){ + // MPI 1 is the hard process. We do not veto that! + if(nMPI < 2){ + return false; + } + + // start at the end of the event record and work back + // This is prior to showering, so there should be at most 2 new MPI emissions + // event[0] is documentation, so stop before that. + size_t nEmissions=0; + for(int ii=event.size()-1; ii > 0 && nEmissions != 2; --ii){ + if(event[ii].status() != 33) continue; + if(event[ii].pT() > m_pTCut){ + return true; + } + + ++nEmissions; + } + + return false; + } + + /// Switch on calling of doVetoMPIStep + bool canVetoMPIStep(){return true;} + /// Call doVetoMIStep three times + /// First is the hard process + /// second is first MPI emission + /// *or* + /// the second part of a double diffractive event + /// *or* + /// the second hard process if there is on. + /// Therefore check up to 3 + int numberVetoMPIStep(){return m_nMPIVeto;} + /// Switch on veto of ISR + bool canVetoISREmission(){return false;} + /// Switch off veto of FSR + bool canVetoFSREmission(){return false;} + + private: + + double m_pTCut; + + int m_nMPIVeto; + + }; + + + +} Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks/UserHookUtils.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks/UserHookUtils.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks/UserHookUtils.hh (revision 921) @@ -0,0 +1,125 @@ +#ifndef SACRIFICE_USERHOOKUTILS_HH +#define SACRIFICE_USERHOOKUTILS_HH +#ifdef PYTHIA8176 +#include "Event.h" +#else +#include "Pythia8/Event.h" +#endif + +#include <stdexcept> + +/** + * Some common functions for determining pTs and navigating event records for the PoWHEG + Pythia user hooks + */ + +namespace Sacrifice{ + + /** + * \return the dot product of \param leg and \param comparison + */ + inline double pTProj(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){ + return leg.px()*comparison.px() + leg.py()*comparison.py() + leg.pz()*comparison.pz(); + } + + /** + * \return the dot product of the legs in the \param evt with indices + * \param legIndex and \param comparedIndex + */ + inline double pTProj(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){ + return pTProj(evt[legIndex], evt[comparedIndex]); + } + + /** + * \return the pT squared of \param leg relative to \param comparison + */ + inline double pT2Leg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){ + double proj = pTProj(leg, comparison); + return leg.pAbs2() - (proj*proj) / comparison.pAbs2(); + } + + /** + * \return the pT squared of the leg with index \param legIndex compared to the leg with index + * \param comparedIndex in Event \param evt + */ + inline double pT2Leg(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){ + return pT2Leg(evt[legIndex], evt[comparedIndex]); + } + + /** + * \return the pT of \param leg relative to \param comparison + */ + inline double pTLeg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){ + return sqrt(pT2Leg(leg, comparison)); + } + + /** + * \return the pT of the leg with index \param legIndex compared to the leg with index + * \param comparedIndex in Event \param evt + */ + inline double pTLeg(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){ + return sqrt(pT2Leg(legIndex, comparedIndex, evt)); + } + + /** + * Return the PowHEG d_ij measure + */ + inline double pTPowheg(const Pythia8::Particle &leg1, const Pythia8::Particle &leg2){ + return sqrt((leg1.p() + leg2.p()).m2Calc()*leg1.e()*leg2.e())/(leg1.e() + leg2.e()); + } + + + /** + * Return the index of the most recent emission in a \param evt with a given \param status + */ + inline size_t findLastEmission(const Pythia8::Event &evt, int status){ + size_t emission = evt.size() - 1; + + while(emission != 0){ + if (evt[emission].isFinal() && evt[emission].status() == status) return emission; + + --emission; + } + + return 0; + } + + /** + * \return the index of the most recent ISR emission in an \param evt + */ + inline size_t findLastISREmission(const Pythia8::Event &evt){ + size_t emission = findLastEmission(evt, 43); + if(emission == 0) throw std::runtime_error("findLastISREmission:: Could not find ISR emission"); + return emission; + } + + /** + * \return the index of the most recent FSR emission in an \param evt + */ + inline size_t findLastFSREmission(const Pythia8::Event &evt){ + size_t emission = findLastEmission(evt, 51); + if(emission == 0) throw std::runtime_error("findLastFSREmission:: Could not find FSR emission"); + return emission; + } + + /** + * \return the index of the most recent particle to radiate an ISR emission in an \param evt + */ + + inline size_t findLastISRRadiator(const Pythia8::Event &evt){ + size_t radiator = findLastEmission(evt, -41); + if(radiator == 0) throw std::runtime_error("findLastISRRadiator:: Could not find ISR radiator"); + return radiator; + } + + /** + * \return the index of the most recent particle to radiate a FSR emission in an \param evt + */ + + inline size_t findLastFSRRadiator(const Pythia8::Event &evt){ + size_t emitted = findLastFSREmission(evt); + return evt[emitted].mother1(); + } + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/UserHooks =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/UserHooks (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/UserHooks (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/UserHooks ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,8 ## +*~ +._* +Makefile.in +Makefile +.deps +*.o +*.lo +*.la Index: tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CTEQ6L1.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CTEQ6L1.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CTEQ6L1.params (revision 921) @@ -0,0 +1,18 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:pSet= LHAPDF5:cteq6ll.LHpdf +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.00 +MultipartonInteractions:pT0Ref = 2.13 +MultipartonInteractions:ecmPow = 0.21 +ColourReconnection:range = 2.21 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/AU2-MSTW2008LO.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/AU2-MSTW2008LO.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/AU2-MSTW2008LO.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = MSTW2008lo68cl.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.01 +MultipartonInteractions:pT0Ref = 1.87 +MultipartonInteractions:ecmPow = 0.28 +BeamRemnants:reconnectRange = 5.32 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CT10.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CT10.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CT10.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = CT10.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.10 +MultipartonInteractions:pT0Ref = 1.70 +MultipartonInteractions:ecmPow = 0.16 +BeamRemnants:reconnectRange = 4.67 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Makefile.am (revision 921) @@ -0,0 +1,16 @@ +pythiamaindir=$(datadir)/Sacrifice + +nodist_pythiamain_DATA = setupPythia.sh + +dist_pythiamain_DATA = A2-MSTW2008LO.params \ + A2-CTEQ6L1.params \ + A14-NNPDF23LO.params \ + AU2-CT10.params \ + AU2-CTEQ6L1.params \ + AU2-MSTW2008LO.params + +dist_pythiamain_DATA += Py81X_A2-MSTW2008LO.params \ + Py81X_A2-CTEQ6L1.params \ + Py81X_AU2-CT10.params \ + Py81X_AU2-CTEQ6L1.params \ + Py81X_AU2-MSTW2008LO.params Index: tags/Sacrifice-1.1.1/Sacrifice/share/A14-NNPDF23LO.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/A14-NNPDF23LO.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/A14-NNPDF23LO.params (revision 921) @@ -0,0 +1,24 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A14 settings +Tune:ee = 7 +Tune:pp = 14 +PDF:pSet= LHAPDF6:NNPDF23_lo_as_0130_qed +SpaceShower:rapidityOrder = on +SigmaProcess:alphaSvalue = 0.140 +SpaceShower:pT0Ref = 1.56 +SpaceShower:pTmaxFudge = 0.91 +SpaceShower:pTdampFudge = 1.05 +SpaceShower:alphaSvalue = 0.127 +TimeShower:alphaSvalue = 0.127 +BeamRemnants:primordialKThard = 1.88 +MultipartonInteractions:pT0Ref = 2.09 +MultipartonInteractions:alphaSvalue = 0.126 +ColourReconnection:range = 1.71 Index: tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-CTEQ6L1.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-CTEQ6L1.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-CTEQ6L1.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = cteq6ll.LHpdf +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.06 +MultipartonInteractions:pT0Ref = 2.18 +MultipartonInteractions:ecmPow = 0.22 +BeamRemnants:reconnectRange = 1.55 +SpaceShower:rapidityOrder=0 \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-MSTW2008LO.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-MSTW2008LO.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_A2-MSTW2008LO.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = MSTW2008lo68cl.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.03 +MultipartonInteractions:pT0Ref = 1.90 +MultipartonInteractions:ecmPow = 0.30 +BeamRemnants:reconnectRange = 2.28 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/setupPythia.sh.in =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/setupPythia.sh.in (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/setupPythia.sh.in (revision 921) @@ -0,0 +1,7 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +export PATH="$exec_prefix/bin:$PATH" +export @LIBPATHVARNAME@="@PYTHIA_LIBDIR@:@PHOTOS_LIBDIR@:@LHAPDF_LIBDIR@:@HEPMC_LIBDIR@:$@LIBPATHVARNAME@" +export LHAPATH="@LHAPDF_LHAPATH@" +#export PYTHIA8DATA="@PYTHIA_DATA@" Index: tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CT10.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CT10.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/AU2-CT10.params (revision 921) @@ -0,0 +1,18 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:pSet = LHAPDF5:CT10.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.10 +MultipartonInteractions:pT0Ref = 1.70 +MultipartonInteractions:ecmPow = 0.16 +ColourReconnection:range = 4.67 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CTEQ6L1.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CTEQ6L1.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-CTEQ6L1.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = cteq6ll.LHpdf +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.00 +MultipartonInteractions:pT0Ref = 2.13 +MultipartonInteractions:ecmPow = 0.21 +BeamRemnants:reconnectRange = 2.21 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-MSTW2008LO.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-MSTW2008LO.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/Py81X_AU2-MSTW2008LO.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = MSTW2008lo68cl.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.01 +MultipartonInteractions:pT0Ref = 1.87 +MultipartonInteractions:ecmPow = 0.28 +BeamRemnants:reconnectRange = 5.32 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/A2-CTEQ6L1.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/A2-CTEQ6L1.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/A2-CTEQ6L1.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +PDF:useLHAPDF = on +PDF:LHAPDFset = cteq6ll.LHpdf +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.06 +MultipartonInteractions:pT0Ref = 2.18 +MultipartonInteractions:ecmPow = 0.22 +BeamRemnants:reconnectRange = 1.55 +SpaceShower:rapidityOrder=0 \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share/A2-MSTW2008LO.params =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share/A2-MSTW2008LO.params (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/share/A2-MSTW2008LO.params (revision 921) @@ -0,0 +1,19 @@ + +6:m0 = 172.5 +23:m0 = 91.1876 +24:m0 = 80.399 + +#CTau lifetime cut +ParticleDecays:limitTau0 = on +ParticleDecays:tau0Max = 10.0 + +# Tune A2 settings +Tune:pp = 5 +Tune:preferLHAPDF = 2 +PDF:pSet = LHAPDF5:MSTW2008lo68cl.LHgrid +MultipartonInteractions:bProfile = 4 +MultipartonInteractions:a1 = 0.03 +MultipartonInteractions:pT0Ref = 1.90 +MultipartonInteractions:ecmPow = 0.30 +ColourReconnection:range = 2.28 +SpaceShower:rapidityOrder=off \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/share =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/share (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/share (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/share ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,5 ## +._* +*~ +setupPythia.sh +Makefile.in +Makefile Index: tags/Sacrifice-1.1.1/Sacrifice/configure.ac =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/configure.ac (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/configure.ac (revision 921) @@ -0,0 +1,164 @@ +AC_PREREQ(2.59) + +AC_INIT( [Sacrifice], [1.1.1], [jmonk@cern.ch], [Sacrifice]) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_SRCDIR([src/PythiaMain.cxx]) +AC_CONFIG_HEADERS([config/config.h]) +AM_INIT_AUTOMAKE +AC_CONFIG_MACRO_DIR([m4]) +AC_SUBST(LT_OBJDIR) +AC_LANG(C++) + +AC_PROG_CXX +AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) +AC_PROG_INSTALL +AC_PROG_LIBTOOL +AC_PROG_LN_S +AM_PROG_CC_C_O +## LT_INIT doesn't work with autoconf 2.59 +#LT_INIT + +##These are for tclap +AC_CXX_HAVE_SSTREAM +AC_CXX_HAVE_STRSTREAM + +# lib suffix differs on OS X +AC_DEFINE_DYNAMIC_LIBS + +# Do we have and LCG tag, AFS area. +# Can user-define the LCG tag for annoying cases (CENT OS!) + +AC_ARG_WITH([LCGTag], + [AC_HELP_STRING([--with-LCGTag], [Specify the LCG tag (default=auto detect)])], + [auto_lcg=no], [auto_lcg=yes]) + +AS_IF([test x$auto_lcg == xno], + [LCG_TAG=$with_LCGTag], + [LCG_TAG=no] + ) + +AC_SEARCH_LCG + +AC_GET_MCUTILS([AC_MSG_NOTICE([MCUtils headers present in include/MCUtils])],[AC_MSG_ERROR([Unable to download MCUtils or HEPUtils headers])]) + +AC_ARG_WITH([MCUtils], + [AC_HELP_STRING([--with-MCUtils], [enable MCUtils for HepMC filtering and (optionally) give the installation location (default disabled)])], + [],[with_MCUtils=yes]) + +AC_ARG_WITH([HepMC], + [AC_HELP_STRING([--with-HepMC], [enable HepMC and give the installation location (=no to disable)])], + ) + +AS_IF([test x$with_HepMC != xno], + [AC_SEARCH_HEPMC([enable_HepMC=yes], + [AS_IF( [test x$with_HepMC = x], [enable_HepMC=no], [AC_MSG_ERROR([HepMC package requested but not found!!])])])], + [enable_HepMC=no]) + +if test x$enable_HepMC = xyes; then + AC_MSG_NOTICE([Building with HepMC]) + AS_IF([test x$with_MCUtils != xno], + [AC_SEARCH_MCUTILS([enable_MCUtils=yes], + [AC_MSG_ERROR([MCUtils support requested, but package not found!!])])], + [enable_MCUtils=no]) +else + AC_MSG_NOTICE([*** Not building with HepMC - output of HepMC events will be disabled!! ***]) + if test x$with_MCUtils != xno ; then + AC_MSG_ERROR([MCUtils support requested, but HepMC not found or requested!]) + fi +fi + +AM_CONDITIONAL(ENABLE_HEPMC, [test x$enable_HepMC = xyes]) +AM_CONDITIONAL(ENABLE_MCUTILS, [test x$enable_MCUtils = xyes]) + +AC_ARG_WITH([pythia_version], + [AC_HELP_STRING([--with-pythia-version], [Request a particular Pythia 8 version if using AFS/LCG])], + [do_pythia_version=yes], [do_pythia_version=no]) + +AS_IF([test x$do_pythia_version == xyes], + [PYTHIA_VERSION=$with_pythia_version], + [PYTHIA_VERSION=no] + ) + +AC_ARG_WITH([LHAPDF], + [AC_HELP_STRING([--with-LHAPDF], [enable LHAPDF and give the installation location (=no to disable)])], + ) + +AS_IF([test x$with_LHAPDF != xno], + [AC_SEARCH_LHAPDF([enable_LHAPDF=yes], + [AS_IF( [test x$with_LHAPDF = x], [enable_LHAPDF=no], [AC_MSG_ERROR([LHAPDF package requested but not found!!])])])], + [enable_LHAPDF=no]) + +if test x$enable_LHAPDF = xyes; then + AC_MSG_NOTICE([Building with LHAPDF]) +else + AC_MSG_NOTICE([*** Not building with LHAPDF - use of external PDF sets will be disabled!! ***]) +fi + +AM_CONDITIONAL(ENABLE_LHAPDF, [test x$enable_LHAPDF = xyes]) + +AC_ARG_WITH([photos], + [AC_HELP_STRING([--with-photos], [enable Photos and give the installation location (default disabled)])], + [test_photos=yes],[test_photos=no]) + +## +AC_ARG_ENABLE([photos], + [AC_HELP_STRING([--enable-photos], [Enable Photos++ and search default paths for libraries])], + [test_photos=yes], + []) + +## + + +AS_IF( [test x$test_photos = xyes ], + [AS_IF( [test x$with_photos != xno ], + [AC_SEARCH_PHOTOS([enable_photos=yes], + [AC_MSG_ERROR([Photos++ support requested but package not found!!])])], + [enable_photos=no])], + [enable_photos=no]) + +if test x$enable_photos = xyes; then + AC_MSG_NOTICE([Building with Photos++ support]) +else + AC_MSG_NOTICE([*** Building without Photos++ support!! ***]) +fi + +AM_CONDITIONAL(ENABLE_PHOTOS, [test x$enable_photos = xyes]) + +AC_ARG_WITH([pythia], + [AC_HELP_STRING([--with-pythia], [Give the Pythia 8 library and header installation location])], + ) + +AC_SEARCH_PYTHIA([AC_MSG_NOTICE([Found Pythia 8 library and headers])], + [AC_MSG_ERROR([Could not find Pythia 8 library and headers!!])]) + +AX_CHECK_ZLIB([have_zlib=yes],[have_zlib=no]) + +AC_MSG_NOTICE([have zlib = $have_zlib ]) +AM_CONDITIONAL(ENABLE_GZIP, [test x$have_zlib = xyes] ) + +AM_CXXFLAGS="$AM_CXXFLAGS -Wall -O2" +AM_CPPFLAGS="$AM_CPPFLAGS -Wall -O2 -I\$(top_builddir)/ -I\$(top_builddir)/include" + +if test x$have_zlib = xyes ; then + AM_LDFLAGS="$AM_LDFLAGS -L${ZLIB_HOME}/lib -lz" + AM_CPPFLAGS="$AM_CPPFLAGS -I${ZLIB_HOME}/include" + AM_CXXFLAGS="$AM_CPPFLAGS -I${ZLIB_HOME}/include" + AC_SUBST(AM_LDFLAGS) +fi + + +AC_SUBST(AM_CXXFLAGS) +AC_SUBST(AM_CPPFLAGS) + +AC_CONFIG_FILES([ Makefile + src/Makefile + include/Makefile + include/Sacrifice/Makefile + include/MCUtils/Makefile + include/HEPUtils/Makefile + include/tclap/Makefile + share/Makefile + share/setupPythia.sh + UserHooks/Makefile ]) + +AC_OUTPUT Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/SwitchArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/SwitchArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/SwitchArg.h (revision 921) @@ -0,0 +1,228 @@ + +/****************************************************************************** + * + * file: SwitchArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_SWITCH_ARG_H +#define TCLAP_SWITCH_ARG_H + +#include <string> +#include <vector> + +#include <tclap/Arg.h> + +namespace TCLAP { + +/** + * A simple switch argument. If the switch is set on the command line, then + * the getValue method will return the opposite of the default value for the + * switch. + */ +class SwitchArg : public Arg +{ + protected: + + /** + * The value of the switch. + */ + bool _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + bool _default; + + public: + + /** + * SwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param def - The default value for this Switch. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool def = false, + Visitor* v = NULL); + + + /** + * SwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param parser - A CmdLine parser object to add this Arg to + * \param def - The default value for this Switch. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + bool def = false, + Visitor* v = NULL); + + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Checks a string to see if any of the chars in the string + * match the flag for this Switch. + */ + bool combinedSwitchesMatch(std::string& combined); + + /** + * Returns bool, whether or not the switch has been set. + */ + bool getValue(); + + virtual void reset(); + +}; + +////////////////////////////////////////////////////////////////////// +//BEGIN SwitchArg.cpp +////////////////////////////////////////////////////////////////////// +inline SwitchArg::SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool default_val, + Visitor* v ) +: Arg(flag, name, desc, false, false, v), + _value( default_val ), + _default( default_val ) +{ } + +inline SwitchArg::SwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + bool default_val, + Visitor* v ) +: Arg(flag, name, desc, false, false, v), + _value( default_val ), + _default(default_val) +{ + parser.add( this ); +} + +inline bool SwitchArg::getValue() { return _value; } + +inline bool SwitchArg::combinedSwitchesMatch(std::string& combinedSwitches ) +{ + // make sure this is actually a combined switch + if ( combinedSwitches.length() > 0 && + combinedSwitches[0] != Arg::flagStartString()[0] ) + return false; + + // make sure it isn't a long name + if ( combinedSwitches.substr( 0, Arg::nameStartString().length() ) == + Arg::nameStartString() ) + return false; + + // make sure the delimiter isn't in the string + if ( combinedSwitches.find_first_of( Arg::delimiter() ) != std::string::npos ) + return false; + + // ok, we're not specifying a ValueArg, so we know that we have + // a combined switch list. + for ( unsigned int i = 1; i < combinedSwitches.length(); i++ ) + if ( _flag.length() > 0 && + combinedSwitches[i] == _flag[0] && + _flag[0] != Arg::flagStartString()[0] ) + { + // update the combined switches so this one is no longer present + // this is necessary so that no unlabeled args are matched + // later in the processing. + //combinedSwitches.erase(i,1); + combinedSwitches[i] = Arg::blankChar(); + return true; + } + + // none of the switches passed in the list match. + return false; +} + + +inline bool SwitchArg::processArg(int *i, std::vector<std::string>& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( argMatches( args[*i] ) || combinedSwitchesMatch( args[*i] ) ) + { + // If we match on a combined switch, then we want to return false + // so that other switches in the combination will also have a + // chance to match. + bool ret = false; + if ( argMatches( args[*i] ) ) + ret = true; + + if ( _alreadySet || ( !ret && combinedSwitchesMatch( args[*i] ) ) ) + throw(CmdLineParseException("Argument already set!", toString())); + + _alreadySet = true; + + if ( _value == true ) + _value = false; + else + _value = true; + + _checkWithVisitor(); + + return ret; + } + else + return false; +} + +inline void SwitchArg::reset() +{ + Arg::reset(); + _value = _default; +} +////////////////////////////////////////////////////////////////////// +//End SwitchArg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineInterface.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineInterface.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineInterface.h (revision 921) @@ -0,0 +1,150 @@ + +/****************************************************************************** + * + * file: CmdLineInterface.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_COMMANDLINE_INTERFACE_H +#define TCLAP_COMMANDLINE_INTERFACE_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <algorithm> + + +namespace TCLAP { + +class Arg; +class CmdLineOutput; +class XorHandler; + +/** + * The base class that manages the command line definition and passes + * along the parsing to the appropriate Arg classes. + */ +class CmdLineInterface +{ + public: + + /** + * Destructor + */ + virtual ~CmdLineInterface() {} + + /** + * Adds an argument to the list of arguments to be parsed. + * \param a - Argument to be added. + */ + virtual void add( Arg& a )=0; + + /** + * An alternative add. Functionally identical. + * \param a - Argument to be added. + */ + virtual void add( Arg* a )=0; + + /** + * Add two Args that will be xor'd. + * If this method is used, add does + * not need to be called. + * \param a - Argument to be added and xor'd. + * \param b - Argument to be added and xor'd. + */ + virtual void xorAdd( Arg& a, Arg& b )=0; + + /** + * Add a list of Args that will be xor'd. If this method is used, + * add does not need to be called. + * \param xors - List of Args to be added and xor'd. + */ + virtual void xorAdd( std::vector<Arg*>& xors )=0; + + /** + * Parses the command line. + * \param argc - Number of arguments. + * \param argv - Array of arguments. + */ + virtual void parse(int argc, const char * const * argv)=0; + + /** + * Parses the command line. + * \param args - A vector of strings representing the args. + * args[0] is still the program name. + */ + void parse(std::vector<std::string>& args); + + /** + * Returns the CmdLineOutput object. + */ + virtual CmdLineOutput* getOutput()=0; + + /** + * \param co - CmdLineOutput object that we want to use instead. + */ + virtual void setOutput(CmdLineOutput* co)=0; + + /** + * Returns the version string. + */ + virtual std::string& getVersion()=0; + + /** + * Returns the program name string. + */ + virtual std::string& getProgramName()=0; + + /** + * Returns the argList. + */ + virtual std::list<Arg*>& getArgList()=0; + + /** + * Returns the XorHandler. + */ + virtual XorHandler& getXorHandler()=0; + + /** + * Returns the delimiter string. + */ + virtual char getDelimiter()=0; + + /** + * Returns the message string. + */ + virtual std::string& getMessage()=0; + + /** + * Indicates whether or not the help and version switches were created + * automatically. + */ + virtual bool hasHelpAndVersion()=0; + + /** + * Resets the instance as if it had just been constructed so that the + * instance can be reused. + */ + virtual void reset()=0; +}; + +} //namespace + + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineOutput.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineOutput.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLineOutput.h (revision 921) @@ -0,0 +1,74 @@ + + +/****************************************************************************** + * + * file: CmdLineOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CMDLINEOUTPUT_H +#define TCLAP_CMDLINEOUTPUT_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <iomanip> +#include <algorithm> + +namespace TCLAP { + +class CmdLineInterface; +class ArgException; + +/** + * The interface that any output object must implement. + */ +class CmdLineOutput +{ + + public: + + /** + * Virtual destructor. + */ + virtual ~CmdLineOutput() {} + + /** + * Generates some sort of output for the USAGE. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c)=0; + + /** + * Generates some sort of output for the version. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c)=0; + + /** + * Generates some sort of output for a failure. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure( CmdLineInterface& c, + ArgException& e )=0; + +}; + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Visitor.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Visitor.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Visitor.h (revision 921) @@ -0,0 +1,53 @@ + +/****************************************************************************** + * + * file: Visitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VISITOR_H +#define TCLAP_VISITOR_H + +namespace TCLAP { + +/** + * A base class that defines the interface for visitors. + */ +class Visitor +{ + public: + + /** + * Constructor. Does nothing. + */ + Visitor() { } + + /** + * Destructor. Does nothing. + */ + virtual ~Visitor() { } + + /** + * Does nothing. Should be overridden by child. + */ + virtual void visit() { } +}; + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledMultiArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledMultiArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledMultiArg.h (revision 921) @@ -0,0 +1,301 @@ + +/****************************************************************************** + * + * file: UnlabeledMultiArg.h + * + * Copyright (c) 2003, Michael E. Smoot. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H +#define TCLAP_MULTIPLE_UNLABELED_ARGUMENT_H + +#include <string> +#include <vector> + +#include <tclap/MultiArg.h> +#include <tclap/OptionalUnlabeledTracker.h> + +namespace TCLAP { + +/** + * Just like a MultiArg, except that the arguments are unlabeled. Basically, + * this Arg will slurp up everything that hasn't been matched to another + * Arg. + */ +template<class T> +class UnlabeledMultiArg : public MultiArg<T> +{ + + // If compiler has two stage name lookup (as gcc >= 3.4 does) + // this is requried to prevent undef. symbols + using MultiArg<T>::_ignoreable; + using MultiArg<T>::_hasBlanks; + using MultiArg<T>::_extractValue; + using MultiArg<T>::_typeDesc; + using MultiArg<T>::_name; + using MultiArg<T>::_description; + using MultiArg<T>::_alreadySet; + using MultiArg<T>::toString; + + public: + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + bool ignoreable = false, + Visitor* v = NULL ); + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Constructor. + * \param name - The name of the Arg. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Whether or not this argument can be ignored + * using the "--" flag. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + UnlabeledMultiArg( const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed from main(). + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Returns the a short id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Returns the a long id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Opertor ==. + * \param a - The Arg to be compared to this. + */ + virtual bool operator==(const Arg& a) const; + + /** + * Pushes this to back of list rather than front. + * \param argList - The list this should be added to. + */ + virtual void addToList( std::list<Arg*>& argList ) const; +}; + +template<class T> +UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + bool ignoreable, + Visitor* v) +: MultiArg<T>("", name, desc, req, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); +} + +template<class T> +UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: MultiArg<T>("", name, desc, req, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); + parser.add( this ); +} + + +template<class T> +UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + bool ignoreable, + Visitor* v) +: MultiArg<T>("", name, desc, req, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); +} + +template<class T> +UnlabeledMultiArg<T>::UnlabeledMultiArg(const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: MultiArg<T>("", name, desc, req, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(true, toString()); + parser.add( this ); +} + + +template<class T> +bool UnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args) +{ + + if ( _hasBlanks( args[*i] ) ) + return false; + + // never ignore an unlabeled multi arg + + + // always take the first value, regardless of the start string + _extractValue( args[(*i)] ); + + /* + // continue taking args until we hit the end or a start string + while ( (unsigned int)(*i)+1 < args.size() && + args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && + args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) + _extractValue( args[++(*i)] ); + */ + + _alreadySet = true; + + return true; +} + +template<class T> +std::string UnlabeledMultiArg<T>::shortID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + "> ..."; +} + +template<class T> +std::string UnlabeledMultiArg<T>::longID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + "> (accepted multiple times)"; +} + +template<class T> +bool UnlabeledMultiArg<T>::operator==(const Arg& a) const +{ + if ( _name == a.getName() || _description == a.getDescription() ) + return true; + else + return false; +} + +template<class T> +void UnlabeledMultiArg<T>::addToList( std::list<Arg*>& argList ) const +{ + argList.push_back( const_cast<Arg*>(static_cast<const Arg* const>(this)) ); +} + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgTraits.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgTraits.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgTraits.h (revision 921) @@ -0,0 +1,81 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ArgTraits.h + * + * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +// This is an internal tclap file, you should probably not have to +// include this directly + +#ifndef TCLAP_ARGTRAITS_H +#define TCLAP_ARGTRAITS_H + +namespace TCLAP { + +// We use two empty structs to get compile type specialization +// function to work + +/** + * A value like argument value type is a value that can be set using + * operator>>. This is the default value type. + */ +struct ValueLike { + typedef ValueLike ValueCategory; +}; + +/** + * A string like argument value type is a value that can be set using + * operator=(string). Usefull if the value type contains spaces which + * will be broken up into individual tokens by operator>>. + */ +struct StringLike {}; + +/** + * A class can inherit from this object to make it have string like + * traits. This is a compile time thing and does not add any overhead + * to the inherenting class. + */ +struct StringLikeTrait { + typedef StringLike ValueCategory; +}; + +/** + * A class can inherit from this object to make it have value like + * traits. This is a compile time thing and does not add any overhead + * to the inherenting class. + */ +struct ValueLikeTrait { + typedef ValueLike ValueCategory; +}; + +/** + * Arg traits are used to get compile type specialization when parsing + * argument values. Using an ArgTraits you can specify the way that + * values gets assigned to any particular type during parsing. The two + * supported types are string like and value like. + */ +template<typename T> +struct ArgTraits { + typedef typename T::ValueCategory ValueCategory; + //typedef ValueLike ValueCategory; +}; + +#endif + +} // namespace Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/DocBookOutput.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/DocBookOutput.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/DocBookOutput.h (revision 921) @@ -0,0 +1,299 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: DocBookOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_DOCBOOKOUTPUT_H +#define TCLAP_DOCBOOKOUTPUT_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <algorithm> + +#include <tclap/CmdLineInterface.h> +#include <tclap/CmdLineOutput.h> +#include <tclap/XorHandler.h> +#include <tclap/Arg.h> + +namespace TCLAP { + +/** + * A class that generates DocBook output for usage() method for the + * given CmdLine and its Args. + */ +class DocBookOutput : public CmdLineOutput +{ + + public: + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + protected: + + /** + * Substitutes the char r for string x in string s. + * \param s - The string to operate on. + * \param r - The char to replace. + * \param x - What to replace r with. + */ + void substituteSpecialChars( std::string& s, char r, std::string& x ); + void removeChar( std::string& s, char r); + void basename( std::string& s ); + + void printShortArg(Arg* it); + void printLongArg(Arg* it); + + char theDelimiter; +}; + + +inline void DocBookOutput::version(CmdLineInterface& _cmd) +{ + std::cout << _cmd.getVersion() << std::endl; +} + +inline void DocBookOutput::usage(CmdLineInterface& _cmd ) +{ + std::list<Arg*> argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + std::string version = _cmd.getVersion(); + theDelimiter = _cmd.getDelimiter(); + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList(); + basename(progName); + + std::cout << "<?xml version='1.0'?>" << std::endl; + std::cout << "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\"" << std::endl; + std::cout << "\t\"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\">" << std::endl << std::endl; + + std::cout << "<refentry>" << std::endl; + + std::cout << "<refmeta>" << std::endl; + std::cout << "<refentrytitle>" << progName << "</refentrytitle>" << std::endl; + std::cout << "<manvolnum>1</manvolnum>" << std::endl; + std::cout << "</refmeta>" << std::endl; + + std::cout << "<refnamediv>" << std::endl; + std::cout << "<refname>" << progName << "</refname>" << std::endl; + std::cout << "<refpurpose>" << _cmd.getMessage() << "</refpurpose>" << std::endl; + std::cout << "</refnamediv>" << std::endl; + + std::cout << "<refsynopsisdiv>" << std::endl; + std::cout << "<cmdsynopsis>" << std::endl; + + std::cout << "<command>" << progName << "</command>" << std::endl; + + // xor + for ( int i = 0; (unsigned int)i < xorList.size(); i++ ) + { + std::cout << "<group choice='req'>" << std::endl; + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); it++ ) + printShortArg((*it)); + + std::cout << "</group>" << std::endl; + } + + // rest of args + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + printShortArg((*it)); + + std::cout << "</cmdsynopsis>" << std::endl; + std::cout << "</refsynopsisdiv>" << std::endl; + + std::cout << "<refsect1>" << std::endl; + std::cout << "<title>Description</title>" << std::endl; + std::cout << "<para>" << std::endl; + std::cout << _cmd.getMessage() << std::endl; + std::cout << "</para>" << std::endl; + std::cout << "</refsect1>" << std::endl; + + std::cout << "<refsect1>" << std::endl; + std::cout << "<title>Options</title>" << std::endl; + + std::cout << "<variablelist>" << std::endl; + + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + printLongArg((*it)); + + std::cout << "</variablelist>" << std::endl; + std::cout << "</refsect1>" << std::endl; + + std::cout << "<refsect1>" << std::endl; + std::cout << "<title>Version</title>" << std::endl; + std::cout << "<para>" << std::endl; + std::cout << version << std::endl; + std::cout << "</para>" << std::endl; + std::cout << "</refsect1>" << std::endl; + + std::cout << "</refentry>" << std::endl; + +} + +inline void DocBookOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + static_cast<void>(_cmd); // unused + std::cout << e.what() << std::endl; + throw ExitException(1); +} + +inline void DocBookOutput::substituteSpecialChars( std::string& s, + char r, + std::string& x ) +{ + size_t p; + while ( (p = s.find_first_of(r)) != std::string::npos ) + { + s.erase(p,1); + s.insert(p,x); + } +} + +inline void DocBookOutput::removeChar( std::string& s, char r) +{ + size_t p; + while ( (p = s.find_first_of(r)) != std::string::npos ) + { + s.erase(p,1); + } +} + +inline void DocBookOutput::basename( std::string& s ) +{ + size_t p = s.find_last_of('/'); + if ( p != std::string::npos ) + { + s.erase(0, p + 1); + } +} + +inline void DocBookOutput::printShortArg(Arg* a) +{ + std::string lt = "<"; + std::string gt = ">"; + + std::string id = a->shortID(); + substituteSpecialChars(id,'<',lt); + substituteSpecialChars(id,'>',gt); + removeChar(id,'['); + removeChar(id,']'); + + std::string choice = "opt"; + if ( a->isRequired() ) + choice = "plain"; + + std::cout << "<arg choice='" << choice << '\''; + if ( a->acceptsMultipleValues() ) + std::cout << " rep='repeat'"; + + + std::cout << '>'; + if ( !a->getFlag().empty() ) + std::cout << a->flagStartChar() << a->getFlag(); + else + std::cout << a->nameStartString() << a->getName(); + if ( a->isValueRequired() ) + { + std::string arg = a->shortID(); + removeChar(arg,'['); + removeChar(arg,']'); + removeChar(arg,'<'); + removeChar(arg,'>'); + arg.erase(0, arg.find_last_of(theDelimiter) + 1); + std::cout << theDelimiter; + std::cout << "<replaceable>" << arg << "</replaceable>"; + } + std::cout << "</arg>" << std::endl; + +} + +inline void DocBookOutput::printLongArg(Arg* a) +{ + std::string lt = "<"; + std::string gt = ">"; + + std::string desc = a->getDescription(); + substituteSpecialChars(desc,'<',lt); + substituteSpecialChars(desc,'>',gt); + + std::cout << "<varlistentry>" << std::endl; + + if ( !a->getFlag().empty() ) + { + std::cout << "<term>" << std::endl; + std::cout << "<option>"; + std::cout << a->flagStartChar() << a->getFlag(); + std::cout << "</option>" << std::endl; + std::cout << "</term>" << std::endl; + } + + std::cout << "<term>" << std::endl; + std::cout << "<option>"; + std::cout << a->nameStartString() << a->getName(); + if ( a->isValueRequired() ) + { + std::string arg = a->shortID(); + removeChar(arg,'['); + removeChar(arg,']'); + removeChar(arg,'<'); + removeChar(arg,'>'); + arg.erase(0, arg.find_last_of(theDelimiter) + 1); + std::cout << theDelimiter; + std::cout << "<replaceable>" << arg << "</replaceable>"; + } + std::cout << "</option>" << std::endl; + std::cout << "</term>" << std::endl; + + std::cout << "<listitem>" << std::endl; + std::cout << "<para>" << std::endl; + std::cout << desc << std::endl; + std::cout << "</para>" << std::endl; + std::cout << "</listitem>" << std::endl; + + std::cout << "</varlistentry>" << std::endl; +} + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/IgnoreRestVisitor.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/IgnoreRestVisitor.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/IgnoreRestVisitor.h (revision 921) @@ -0,0 +1,52 @@ + +/****************************************************************************** + * + * file: IgnoreRestVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_IGNORE_REST_VISITOR_H +#define TCLAP_IGNORE_REST_VISITOR_H + +#include <tclap/Visitor.h> +#include <tclap/Arg.h> + +namespace TCLAP { + +/** + * A Vistor that tells the CmdLine to begin ignoring arguments after + * this one is parsed. + */ +class IgnoreRestVisitor: public Visitor +{ + public: + + /** + * Constructor. + */ + IgnoreRestVisitor() : Visitor() {} + + /** + * Sets Arg::_ignoreRest. + */ + void visit() { Arg::beginIgnoring(); } +}; + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValuesConstraint.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValuesConstraint.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValuesConstraint.h (revision 921) @@ -0,0 +1,147 @@ + + +/****************************************************************************** + * + * file: ValuesConstraint.h + * + * Copyright (c) 2005, Michael E. Smoot + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_VALUESCONSTRAINT_H +#define TCLAP_VALUESCONSTRAINT_H + +#include <string> +#include <vector> +#include <tclap/Constraint.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#else +#define HAVE_SSTREAM +#endif + +#if defined(HAVE_SSTREAM) +#include <sstream> +#elif defined(HAVE_STRSTREAM) +#include <strstream> +#else +#error "Need a stringstream (sstream or strstream) to compile!" +#endif + +namespace TCLAP { + +/** + * A Constraint that constrains the Arg to only those values specified + * in the constraint. + */ +template<class T> +class ValuesConstraint : public Constraint<T> +{ + + public: + + /** + * Constructor. + * \param allowed - vector of allowed values. + */ + ValuesConstraint(std::vector<T>& allowed); + + /** + * Virtual destructor. + */ + virtual ~ValuesConstraint() {} + + /** + * Returns a description of the Constraint. + */ + virtual std::string description() const; + + /** + * Returns the short ID for the Constraint. + */ + virtual std::string shortID() const; + + /** + * The method used to verify that the value parsed from the command + * line meets the constraint. + * \param value - The value that will be checked. + */ + virtual bool check(const T& value) const; + + protected: + + /** + * The list of valid values. + */ + std::vector<T> _allowed; + + /** + * The string used to describe the allowed values of this constraint. + */ + std::string _typeDesc; + +}; + +template<class T> +ValuesConstraint<T>::ValuesConstraint(std::vector<T>& allowed) +: _allowed(allowed) +{ + for ( unsigned int i = 0; i < _allowed.size(); i++ ) + { + +#if defined(HAVE_SSTREAM) + std::ostringstream os; +#elif defined(HAVE_STRSTREAM) + std::ostrstream os; +#else +#error "Need a stringstream (sstream or strstream) to compile!" +#endif + + os << _allowed[i]; + + std::string temp( os.str() ); + + if ( i > 0 ) + _typeDesc += "|"; + _typeDesc += temp; + } +} + +template<class T> +bool ValuesConstraint<T>::check( const T& val ) const +{ + if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) + return false; + else + return true; +} + +template<class T> +std::string ValuesConstraint<T>::shortID() const +{ + return _typeDesc; +} + +template<class T> +std::string ValuesConstraint<T>::description() const +{ + return _typeDesc; +} + + +} //namespace TCLAP +#endif + Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/VersionVisitor.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/VersionVisitor.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/VersionVisitor.h (revision 921) @@ -0,0 +1,74 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: VersionVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VERSION_VISITOR_H +#define TCLAP_VERSION_VISITOR_H + +#include <tclap/CmdLineInterface.h> +#include <tclap/CmdLineOutput.h> +#include <tclap/Visitor.h> + +namespace TCLAP { + +/** + * A Vistor that will call the version method of the given CmdLineOutput + * for the specified CmdLine object and then exit. + */ +class VersionVisitor: public Visitor +{ + protected: + + /** + * The CmdLine of interest. + */ + CmdLineInterface* _cmd; + + /** + * The output object. + */ + CmdLineOutput** _out; + + public: + + /** + * Constructor. + * \param cmd - The CmdLine the output is generated for. + * \param out - The type of output. + */ + VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) + : Visitor(), _cmd( cmd ), _out( out ) { } + + /** + * Calls the version method of the output object using the + * specified CmdLine. + */ + void visit() { + (*_out)->version(*_cmd); + throw ExitException(0); + } + +}; + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiSwitchArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiSwitchArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiSwitchArg.h (revision 921) @@ -0,0 +1,216 @@ + +/****************************************************************************** +* +* file: MultiSwitchArg.h +* +* Copyright (c) 2003, Michael E. Smoot . +* Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. +* Copyright (c) 2005, Michael E. Smoot, Daniel Aarno, Erik Zeek. +* All rights reverved. +* +* See the file COPYING in the top directory of this distribution for +* more information. +* +* THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ + + +#ifndef TCLAP_MULTI_SWITCH_ARG_H +#define TCLAP_MULTI_SWITCH_ARG_H + +#include <string> +#include <vector> + +#include <tclap/SwitchArg.h> + +namespace TCLAP { + +/** +* A multiple switch argument. If the switch is set on the command line, then +* the getValue method will return the number of times the switch appears. +*/ +class MultiSwitchArg : public SwitchArg +{ + protected: + + /** + * The value of the switch. + */ + int _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + int _default; + + public: + + /** + * MultiSwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param init - Optional. The initial/default value of this Arg. + * Defaults to 0. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + int init = 0, + Visitor* v = NULL); + + + /** + * MultiSwitchArg constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param parser - A CmdLine parser object to add this Arg to + * \param init - Optional. The initial/default value of this Arg. + * Defaults to 0. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + int init = 0, + Visitor* v = NULL); + + + /** + * Handles the processing of the argument. + * This re-implements the SwitchArg version of this method to set the + * _value of the argument appropriately. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Returns int, the number of times the switch has been set. + */ + int getValue(); + + /** + * Returns the shortID for this Arg. + */ + std::string shortID(const std::string& val) const; + + /** + * Returns the longID for this Arg. + */ + std::string longID(const std::string& val) const; + + void reset(); + +}; + +////////////////////////////////////////////////////////////////////// +//BEGIN MultiSwitchArg.cpp +////////////////////////////////////////////////////////////////////// +inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + int init, + Visitor* v ) +: SwitchArg(flag, name, desc, false, v), +_value( init ), +_default( init ) +{ } + +inline MultiSwitchArg::MultiSwitchArg(const std::string& flag, + const std::string& name, + const std::string& desc, + CmdLineInterface& parser, + int init, + Visitor* v ) +: SwitchArg(flag, name, desc, false, v), +_value( init ), +_default( init ) +{ + parser.add( this ); +} + +inline int MultiSwitchArg::getValue() { return _value; } + +inline bool MultiSwitchArg::processArg(int *i, std::vector<std::string>& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( argMatches( args[*i] )) + { + // so the isSet() method will work + _alreadySet = true; + + // Matched argument: increment value. + ++_value; + + _checkWithVisitor(); + + return true; + } + else if ( combinedSwitchesMatch( args[*i] ) ) + { + // so the isSet() method will work + _alreadySet = true; + + // Matched argument: increment value. + ++_value; + + // Check for more in argument and increment value. + while ( combinedSwitchesMatch( args[*i] ) ) + ++_value; + + _checkWithVisitor(); + + return false; + } + else + return false; +} + +inline std::string +MultiSwitchArg::shortID(const std::string& val) const +{ + return Arg::shortID(val) + " ... "; +} + +inline std::string +MultiSwitchArg::longID(const std::string& val) const +{ + return Arg::longID(val) + " (accepted multiple times)"; +} + +inline void +MultiSwitchArg::reset() +{ + MultiSwitchArg::_value = MultiSwitchArg::_default; +} + +////////////////////////////////////////////////////////////////////// +//END MultiSwitchArg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValueArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValueArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ValueArg.h (revision 921) @@ -0,0 +1,411 @@ +/****************************************************************************** + * + * file: ValueArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_VALUE_ARGUMENT_H +#define TCLAP_VALUE_ARGUMENT_H + +#include <string> +#include <vector> + +#include <tclap/Arg.h> +#include <tclap/Constraint.h> + +namespace TCLAP { + +/** + * The basic labeled argument that parses a value. + * This is a template class, which means the type T defines the type + * that a given object will attempt to parse when the flag/name is matched + * on the command line. While there is nothing stopping you from creating + * an unflagged ValueArg, it is unwise and would cause significant problems. + * Instead use an UnlabeledValueArg. + */ +template<class T> +class ValueArg : public Arg +{ + protected: + + /** + * The value parsed from the command line. + * Can be of any type, as long as the >> operator for the type + * is defined. + */ + T _value; + + /** + * Used to support the reset() method so that ValueArg can be + * reset to their constructed value. + */ + T _default; + + /** + * A human readable description of the type to be parsed. + * This is a hack, plain and simple. Ideally we would use RTTI to + * return the name of type T, but until there is some sort of + * consistent support for human readable names, we are left to our + * own devices. + */ + std::string _typeDesc; + + /** + * A Constraint this Arg must conform to. + */ + Constraint<T>* _constraint; + + /** + * Extracts the value from the string. + * Attempts to parse string as type T, if this fails an exception + * is thrown. + * \param val - value to be parsed. + */ + void _extractValue( const std::string& val ); + + public: + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + Visitor* v = NULL); + + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint<T>* constraint, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Labeled ValueArg constructor. + * You could conceivably call this constructor with a blank flag, + * but that would make you a bad person. It would also cause + * an exception to be thrown. If you want an unlabeled argument, + * use the other constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + ValueArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint<T>* constraint, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed + * in from main(). + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Returns the value of the argument. + */ + T& getValue() ; + + /** + * Specialization of shortID. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val = "val") const; + + /** + * Specialization of longID. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val = "val") const; + + virtual void reset() ; + +}; + + +/** + * Constructor implementation. + */ +template<class T> +ValueArg<T>::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + Visitor* v) +: Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( typeDesc ), + _constraint( NULL ) +{ } + +template<class T> +ValueArg<T>::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v) +: Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( typeDesc ), + _constraint( NULL ) +{ + parser.add( this ); +} + +template<class T> +ValueArg<T>::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint<T>* constraint, + Visitor* v) +: Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( constraint->shortID() ), + _constraint( constraint ) +{ } + +template<class T> +ValueArg<T>::ValueArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint<T>* constraint, + CmdLineInterface& parser, + Visitor* v) +: Arg(flag, name, desc, req, true, v), + _value( val ), + _default( val ), + _typeDesc( constraint->shortID() ), + _constraint( constraint ) +{ + parser.add( this ); +} + + +/** + * Implementation of getValue(). + */ +template<class T> +T& ValueArg<T>::getValue() { return _value; } + +/** + * Implementation of processArg(). + */ +template<class T> +bool ValueArg<T>::processArg(int *i, std::vector<std::string>& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + std::string flag = args[*i]; + + std::string value = ""; + trimFlag( flag, value ); + + if ( argMatches( flag ) ) + { + if ( _alreadySet ) + throw( CmdLineParseException("Argument already set!", toString()) ); + + if ( Arg::delimiter() != ' ' && value == "" ) + throw( ArgParseException( + "Couldn't find delimiter for this argument!", + toString() ) ); + + if ( value == "" ) + { + (*i)++; + if ( static_cast<unsigned int>(*i) < args.size() ) + _extractValue( args[*i] ); + else + throw( ArgParseException("Missing a value for this argument!", + toString() ) ); + } + else + _extractValue( value ); + + _alreadySet = true; + _checkWithVisitor(); + return true; + } + else + return false; +} + +/** + * Implementation of shortID. + */ +template<class T> +std::string ValueArg<T>::shortID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return Arg::shortID( _typeDesc ); +} + +/** + * Implementation of longID. + */ +template<class T> +std::string ValueArg<T>::longID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return Arg::longID( _typeDesc ); +} + +template<class T> +void ValueArg<T>::_extractValue( const std::string& val ) +{ + try { + ExtractValue(_value, val, typename ArgTraits<T>::ValueCategory()); + } catch( ArgParseException &e) { + throw ArgParseException(e.error(), toString()); + } + + if ( _constraint != NULL ) + if ( ! _constraint->check( _value ) ) + throw( CmdLineParseException( "Value '" + val + + + "' does not meet constraint: " + + _constraint->description(), + toString() ) ); +} + +template<class T> +void ValueArg<T>::reset() +{ + Arg::reset(); + _value = _default; +} + +} // namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/XorHandler.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/XorHandler.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/XorHandler.h (revision 921) @@ -0,0 +1,156 @@ + +/****************************************************************************** + * + * file: XorHandler.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_XORHANDLER_H +#define TCLAP_XORHANDLER_H + +#include <tclap/Arg.h> +#include <string> +#include <vector> +#include <algorithm> +#include <iostream> + +namespace TCLAP { + +/** + * This class handles lists of Arg's that are to be XOR'd on the command + * line. This is used by CmdLine and you shouldn't ever use it. + */ +class XorHandler +{ + protected: + + /** + * The list of of lists of Arg's to be or'd together. + */ + std::vector< std::vector<Arg*> > _orList; + + public: + + /** + * Constructor. Does nothing. + */ + XorHandler( ) {} + + /** + * Add a list of Arg*'s that will be orred together. + * \param ors - list of Arg* that will be xor'd. + */ + void add( std::vector<Arg*>& ors ); + + /** + * Checks whether the specified Arg is in one of the xor lists and + * if it does match one, returns the size of the xor list that the + * Arg matched. If the Arg matches, then it also sets the rest of + * the Arg's in the list. You shouldn't use this. + * \param a - The Arg to be checked. + */ + int check( const Arg* a ); + + /** + * Returns the XOR specific short usage. + */ + std::string shortUsage(); + + /** + * Prints the XOR specific long usage. + * \param os - Stream to print to. + */ + void printLongUsage(std::ostream& os); + + /** + * Simply checks whether the Arg is contained in one of the arg + * lists. + * \param a - The Arg to be checked. + */ + bool contains( const Arg* a ); + + std::vector< std::vector<Arg*> >& getXorList(); + +}; + + +////////////////////////////////////////////////////////////////////// +//BEGIN XOR.cpp +////////////////////////////////////////////////////////////////////// +inline void XorHandler::add( std::vector<Arg*>& ors ) +{ + _orList.push_back( ors ); +} + +inline int XorHandler::check( const Arg* a ) +{ + // iterate over each XOR list + for ( int i = 0; static_cast<unsigned int>(i) < _orList.size(); i++ ) + { + // if the XOR list contains the arg.. + ArgVectorIterator ait = std::find( _orList[i].begin(), + _orList[i].end(), a ); + if ( ait != _orList[i].end() ) + { + // go through and set each arg that is not a + for ( ArgVectorIterator it = _orList[i].begin(); + it != _orList[i].end(); + it++ ) + if ( a != (*it) ) + (*it)->xorSet(); + + // return the number of required args that have now been set + if ( (*ait)->allowMore() ) + return 0; + else + return static_cast<int>(_orList[i].size()); + } + } + + if ( a->isRequired() ) + return 1; + else + return 0; +} + +inline bool XorHandler::contains( const Arg* a ) +{ + for ( int i = 0; static_cast<unsigned int>(i) < _orList.size(); i++ ) + for ( ArgVectorIterator it = _orList[i].begin(); + it != _orList[i].end(); + it++ ) + if ( a == (*it) ) + return true; + + return false; +} + +inline std::vector< std::vector<Arg*> >& XorHandler::getXorList() +{ + return _orList; +} + + + +////////////////////////////////////////////////////////////////////// +//END XOR.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/HelpVisitor.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/HelpVisitor.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/HelpVisitor.h (revision 921) @@ -0,0 +1,69 @@ + +/****************************************************************************** + * + * file: HelpVisitor.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_HELP_VISITOR_H +#define TCLAP_HELP_VISITOR_H + +#include <tclap/CmdLineInterface.h> +#include <tclap/CmdLineOutput.h> +#include <tclap/Visitor.h> + +namespace TCLAP { + +/** + * A Visitor object that calls the usage method of the given CmdLineOutput + * object for the specified CmdLine object. + */ +class HelpVisitor: public Visitor +{ + protected: + + /** + * The CmdLine the output will be generated for. + */ + CmdLineInterface* _cmd; + + /** + * The output object. + */ + CmdLineOutput** _out; + + public: + + /** + * Constructor. + * \param cmd - The CmdLine the output will be generated for. + * \param out - The type of output. + */ + HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) + : Visitor(), _cmd( cmd ), _out( out ) { } + + /** + * Calls the usage method of the CmdLineOutput for the + * specified CmdLine. + */ + void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } + +}; + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Arg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Arg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Arg.h (revision 921) @@ -0,0 +1,672 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: Arg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_ARGUMENT_H +#define TCLAP_ARGUMENT_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#else +#define HAVE_SSTREAM +#endif + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <iomanip> +#include <cstdio> + +#if defined(HAVE_SSTREAM) +#include <sstream> +typedef std::istringstream istringstream; +#elif defined(HAVE_STRSTREAM) +#include <strstream> +typedef std::istrstream istringstream; +#else +#error "Need a stringstream (sstream or strstream) to compile!" +#endif + +#include <tclap/ArgException.h> +#include <tclap/Visitor.h> +#include <tclap/CmdLineInterface.h> +#include <tclap/ArgTraits.h> +#include <tclap/StandardTraits.h> + +namespace TCLAP { + +/** + * A virtual base class that defines the essential data for all arguments. + * This class, or one of its existing children, must be subclassed to do + * anything. + */ +class Arg +{ + private: + + /** + * Indicates whether the rest of the arguments should be ignored. + */ + static bool& ignoreRestRef() { static bool ign = false; return ign; } + + /** + * The delimiter that separates an argument flag/name from the + * value. + */ + static char& delimiterRef() { static char delim = ' '; return delim; } + + protected: + + /** + * The single char flag used to identify the argument. + * This value (preceded by a dash {-}), can be used to identify + * an argument on the command line. The _flag can be blank, + * in fact this is how unlabeled args work. Unlabeled args must + * override appropriate functions to get correct handling. Note + * that the _flag does NOT include the dash as part of the flag. + */ + std::string _flag; + + /** + * A single work namd indentifying the argument. + * This value (preceded by two dashed {--}) can also be used + * to identify an argument on the command line. Note that the + * _name does NOT include the two dashes as part of the _name. The + * _name cannot be blank. + */ + std::string _name; + + /** + * Description of the argument. + */ + std::string _description; + + /** + * Indicating whether the argument is required. + */ + bool _required; + + /** + * Label to be used in usage description. Normally set to + * "required", but can be changed when necessary. + */ + std::string _requireLabel; + + /** + * Indicates whether a value is required for the argument. + * Note that the value may be required but the argument/value + * combination may not be, as specified by _required. + */ + bool _valueRequired; + + /** + * Indicates whether the argument has been set. + * Indicates that a value on the command line has matched the + * name/flag of this argument and the values have been set accordingly. + */ + bool _alreadySet; + + /** + * A pointer to a vistitor object. + * The visitor allows special handling to occur as soon as the + * argument is matched. This defaults to NULL and should not + * be used unless absolutely necessary. + */ + Visitor* _visitor; + + /** + * Whether this argument can be ignored, if desired. + */ + bool _ignoreable; + + /** + * Indicates that the arg was set as part of an XOR and not on the + * command line. + */ + bool _xorSet; + + bool _acceptsMultipleValues; + + /** + * Performs the special handling described by the Vistitor. + */ + void _checkWithVisitor() const; + + /** + * Primary constructor. YOU (yes you) should NEVER construct an Arg + * directly, this is a base class that is extended by various children + * that are meant to be used. Use SwitchArg, ValueArg, MultiArg, + * UnlabeledValueArg, or UnlabeledMultiArg instead. + * + * \param flag - The flag identifying the argument. + * \param name - The name identifying the argument. + * \param desc - The description of the argument, used in the usage. + * \param req - Whether the argument is required. + * \param valreq - Whether the a value is required for the argument. + * \param v - The visitor checked by the argument. Defaults to NULL. + */ + Arg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + bool valreq, + Visitor* v = NULL ); + + public: + /** + * Destructor. + */ + virtual ~Arg(); + + /** + * Adds this to the specified list of Args. + * \param argList - The list to add this to. + */ + virtual void addToList( std::list<Arg*>& argList ) const; + + /** + * Begin ignoring arguments since the "--" argument was specified. + */ + static void beginIgnoring() { ignoreRestRef() = true; } + + /** + * Whether to ignore the rest. + */ + static bool ignoreRest() { return ignoreRestRef(); } + + /** + * The delimiter that separates an argument flag/name from the + * value. + */ + static char delimiter() { return delimiterRef(); } + + /** + * The char used as a place holder when SwitchArgs are combined. + * Currently set to the bell char (ASCII 7). + */ + static char blankChar() { return (char)7; } + + /** + * The char that indicates the beginning of a flag. Currently '-'. + */ + static char flagStartChar() { return '-'; } + + /** + * The sting that indicates the beginning of a flag. Currently "-". + * Should be identical to flagStartChar. + */ + static const std::string flagStartString() { return "-"; } + + /** + * The sting that indicates the beginning of a name. Currently "--". + * Should be flagStartChar twice. + */ + static const std::string nameStartString() { return "--"; } + + /** + * The name used to identify the ignore rest argument. + */ + static const std::string ignoreNameString() { return "ignore_rest"; } + + /** + * Sets the delimiter for all arguments. + * \param c - The character that delimits flags/names from values. + */ + static void setDelimiter( char c ) { delimiterRef() = c; } + + /** + * Pure virtual method meant to handle the parsing and value assignment + * of the string on the command line. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. What is + * passed in from main. + */ + virtual bool processArg(int *i, std::vector<std::string>& args) = 0; + + /** + * Operator ==. + * Equality operator. Must be virtual to handle unlabeled args. + * \param a - The Arg to be compared to this. + */ + virtual bool operator==(const Arg& a) const; + + /** + * Returns the argument flag. + */ + const std::string& getFlag() const; + + /** + * Returns the argument name. + */ + const std::string& getName() const; + + /** + * Returns the argument description. + */ + std::string getDescription() const; + + /** + * Indicates whether the argument is required. + */ + virtual bool isRequired() const; + + /** + * Sets _required to true. This is used by the XorHandler. + * You really have no reason to ever use it. + */ + void forceRequired(); + + /** + * Sets the _alreadySet value to true. This is used by the XorHandler. + * You really have no reason to ever use it. + */ + void xorSet(); + + /** + * Indicates whether a value must be specified for argument. + */ + bool isValueRequired() const; + + /** + * Indicates whether the argument has already been set. Only true + * if the arg has been matched on the command line. + */ + bool isSet() const; + + /** + * Indicates whether the argument can be ignored, if desired. + */ + bool isIgnoreable() const; + + /** + * A method that tests whether a string matches this argument. + * This is generally called by the processArg() method. This + * method could be re-implemented by a child to change how + * arguments are specified on the command line. + * \param s - The string to be compared to the flag/name to determine + * whether the arg matches. + */ + virtual bool argMatches( const std::string& s ) const; + + /** + * Returns a simple string representation of the argument. + * Primarily for debugging. + */ + virtual std::string toString() const; + + /** + * Returns a short ID for the usage. + * \param valueId - The value used in the id. + */ + virtual std::string shortID( const std::string& valueId = "val" ) const; + + /** + * Returns a long ID for the usage. + * \param valueId - The value used in the id. + */ + virtual std::string longID( const std::string& valueId = "val" ) const; + + /** + * Trims a value off of the flag. + * \param flag - The string from which the flag and value will be + * trimmed. Contains the flag once the value has been trimmed. + * \param value - Where the value trimmed from the string will + * be stored. + */ + virtual void trimFlag( std::string& flag, std::string& value ) const; + + /** + * Checks whether a given string has blank chars, indicating that + * it is a combined SwitchArg. If so, return true, otherwise return + * false. + * \param s - string to be checked. + */ + bool _hasBlanks( const std::string& s ) const; + + /** + * Sets the requireLabel. Used by XorHandler. You shouldn't ever + * use this. + * \param s - Set the requireLabel to this value. + */ + void setRequireLabel( const std::string& s ); + + /** + * Used for MultiArgs and XorHandler to determine whether args + * can still be set. + */ + virtual bool allowMore(); + + /** + * Use by output classes to determine whether an Arg accepts + * multiple values. + */ + virtual bool acceptsMultipleValues(); + + /** + * Clears the Arg object and allows it to be reused by new + * command lines. + */ + virtual void reset(); +}; + +/** + * Typedef of an Arg list iterator. + */ +typedef std::list<Arg*>::iterator ArgListIterator; + +/** + * Typedef of an Arg vector iterator. + */ +typedef std::vector<Arg*>::iterator ArgVectorIterator; + +/** + * Typedef of a Visitor list iterator. + */ +typedef std::list<Visitor*>::iterator VisitorListIterator; + +/* + * Extract a value of type T from it's string representation contained + * in strVal. The ValueLike parameter used to select the correct + * specialization of ExtractValue depending on the value traits of T. + * ValueLike traits use operator>> to assign the value from strVal. + */ +template<typename T> void +ExtractValue(T &destVal, const std::string& strVal, ValueLike vl) +{ + static_cast<void>(vl); // Avoid warning about unused vl + std::istringstream is(strVal); + + int valuesRead = 0; + while ( is.good() ) { + if ( is.peek() != EOF ) +#ifdef TCLAP_SETBASE_ZERO + is >> std::setbase(0) >> destVal; +#else + is >> destVal; +#endif + else + break; + + valuesRead++; + } + + if ( is.fail() ) + throw( ArgParseException("Couldn't read argument value " + "from string '" + strVal + "'")); + + + if ( valuesRead > 1 ) + throw( ArgParseException("More than one valid value parsed from " + "string '" + strVal + "'")); + +} + +/* + * Extract a value of type T from it's string representation contained + * in strVal. The ValueLike parameter used to select the correct + * specialization of ExtractValue depending on the value traits of T. + * StringLike uses assignment (operator=) to assign from strVal. + */ +template<typename T> void +ExtractValue(T &destVal, const std::string& strVal, StringLike sl) +{ + static_cast<void>(sl); // Avoid warning about unused sl + SetString(destVal, strVal); +} + +////////////////////////////////////////////////////////////////////// +//BEGIN Arg.cpp +////////////////////////////////////////////////////////////////////// + +inline Arg::Arg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + bool valreq, + Visitor* v) : + _flag(flag), + _name(name), + _description(desc), + _required(req), + _requireLabel("required"), + _valueRequired(valreq), + _alreadySet(false), + _visitor( v ), + _ignoreable(true), + _xorSet(false), + _acceptsMultipleValues(false) +{ + if ( _flag.length() > 1 ) + throw(SpecificationException( + "Argument flag can only be one character long", toString() ) ); + + if ( _name != ignoreNameString() && + ( _flag == Arg::flagStartString() || + _flag == Arg::nameStartString() || + _flag == " " ) ) + throw(SpecificationException("Argument flag cannot be either '" + + Arg::flagStartString() + "' or '" + + Arg::nameStartString() + "' or a space.", + toString() ) ); + + if ( ( _name.substr( 0, Arg::flagStartString().length() ) == Arg::flagStartString() ) || + ( _name.substr( 0, Arg::nameStartString().length() ) == Arg::nameStartString() ) || + ( _name.find( " ", 0 ) != std::string::npos ) ) + throw(SpecificationException("Argument name begin with either '" + + Arg::flagStartString() + "' or '" + + Arg::nameStartString() + "' or space.", + toString() ) ); + +} + +inline Arg::~Arg() { } + +inline std::string Arg::shortID( const std::string& valueId ) const +{ + std::string id = ""; + + if ( _flag != "" ) + id = Arg::flagStartString() + _flag; + else + id = Arg::nameStartString() + _name; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + if ( !_required ) + id = "[" + id + "]"; + + return id; +} + +inline std::string Arg::longID( const std::string& valueId ) const +{ + std::string id = ""; + + if ( _flag != "" ) + { + id += Arg::flagStartString() + _flag; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + id += ", "; + } + + id += Arg::nameStartString() + _name; + + if ( _valueRequired ) + id += std::string( 1, Arg::delimiter() ) + "<" + valueId + ">"; + + return id; + +} + +inline bool Arg::operator==(const Arg& a) const +{ + if ( ( _flag != "" && _flag == a._flag ) || _name == a._name) + return true; + else + return false; +} + +inline std::string Arg::getDescription() const +{ + std::string desc = ""; + if ( _required ) + desc = "(" + _requireLabel + ") "; + +// if ( _valueRequired ) +// desc += "(value required) "; + + desc += _description; + return desc; +} + +inline const std::string& Arg::getFlag() const { return _flag; } + +inline const std::string& Arg::getName() const { return _name; } + +inline bool Arg::isRequired() const { return _required; } + +inline bool Arg::isValueRequired() const { return _valueRequired; } + +inline bool Arg::isSet() const +{ + if ( _alreadySet && !_xorSet ) + return true; + else + return false; +} + +inline bool Arg::isIgnoreable() const { return _ignoreable; } + +inline void Arg::setRequireLabel( const std::string& s) +{ + _requireLabel = s; +} + +inline bool Arg::argMatches( const std::string& argFlag ) const +{ + if ( ( argFlag == Arg::flagStartString() + _flag && _flag != "" ) || + argFlag == Arg::nameStartString() + _name ) + return true; + else + return false; +} + +inline std::string Arg::toString() const +{ + std::string s = ""; + + if ( _flag != "" ) + s += Arg::flagStartString() + _flag + " "; + + s += "(" + Arg::nameStartString() + _name + ")"; + + return s; +} + +inline void Arg::_checkWithVisitor() const +{ + if ( _visitor != NULL ) + _visitor->visit(); +} + +/** + * Implementation of trimFlag. + */ +inline void Arg::trimFlag(std::string& flag, std::string& value) const +{ + int stop = 0; + for ( int i = 0; static_cast<unsigned int>(i) < flag.length(); i++ ) + if ( flag[i] == Arg::delimiter() ) + { + stop = i; + break; + } + + if ( stop > 1 ) + { + value = flag.substr(stop+1); + flag = flag.substr(0,stop); + } + +} + +/** + * Implementation of _hasBlanks. + */ +inline bool Arg::_hasBlanks( const std::string& s ) const +{ + for ( int i = 1; static_cast<unsigned int>(i) < s.length(); i++ ) + if ( s[i] == Arg::blankChar() ) + return true; + + return false; +} + +inline void Arg::forceRequired() +{ + _required = true; +} + +inline void Arg::xorSet() +{ + _alreadySet = true; + _xorSet = true; +} + +/** + * Overridden by Args that need to added to the end of the list. + */ +inline void Arg::addToList( std::list<Arg*>& argList ) const +{ + argList.push_front( const_cast<Arg*>(this) ); +} + +inline bool Arg::allowMore() +{ + return false; +} + +inline bool Arg::acceptsMultipleValues() +{ + return _acceptsMultipleValues; +} + +inline void Arg::reset() +{ + _xorSet = false; + _alreadySet = false; +} + +////////////////////////////////////////////////////////////////////// +//END Arg.cpp +////////////////////////////////////////////////////////////////////// + +} //namespace TCLAP + +#endif + Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StdOutput.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StdOutput.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StdOutput.h (revision 921) @@ -0,0 +1,298 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: StdOutput.h + * + * Copyright (c) 2004, Michael E. Smoot + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_STDCMDLINEOUTPUT_H +#define TCLAP_STDCMDLINEOUTPUT_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <algorithm> + +#include <tclap/CmdLineInterface.h> +#include <tclap/CmdLineOutput.h> +#include <tclap/XorHandler.h> +#include <tclap/Arg.h> + +namespace TCLAP { + +/** + * A class that isolates any output from the CmdLine object so that it + * may be easily modified. + */ +class StdOutput : public CmdLineOutput +{ + + public: + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + protected: + + /** + * Writes a brief usage message with short args. + * \param c - The CmdLine object the output is generated for. + * \param os - The stream to write the message to. + */ + void _shortUsage( CmdLineInterface& c, std::ostream& os ) const; + + /** + * Writes a longer usage message with long and short args, + * provides descriptions and prints message. + * \param c - The CmdLine object the output is generated for. + * \param os - The stream to write the message to. + */ + void _longUsage( CmdLineInterface& c, std::ostream& os ) const; + + /** + * This function inserts line breaks and indents long strings + * according the params input. It will only break lines at spaces, + * commas and pipes. + * \param os - The stream to be printed to. + * \param s - The string to be printed. + * \param maxWidth - The maxWidth allowed for the output line. + * \param indentSpaces - The number of spaces to indent the first line. + * \param secondLineOffset - The number of spaces to indent the second + * and all subsequent lines in addition to indentSpaces. + */ + void spacePrint( std::ostream& os, + const std::string& s, + int maxWidth, + int indentSpaces, + int secondLineOffset ) const; + +}; + + +inline void StdOutput::version(CmdLineInterface& _cmd) +{ + std::string progName = _cmd.getProgramName(); + std::string version = _cmd.getVersion(); + + std::cout << std::endl << progName << " version: " + << version << std::endl << std::endl; +} + +inline void StdOutput::usage(CmdLineInterface& _cmd ) +{ + std::cout << std::endl << "USAGE: " << std::endl << std::endl; + + _shortUsage( _cmd, std::cout ); + + std::cout << std::endl << std::endl << "Where: " << std::endl << std::endl; + + _longUsage( _cmd, std::cout ); + + std::cout << std::endl; + +} + +inline void StdOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + std::string progName = _cmd.getProgramName(); + + std::cerr << "PARSE ERROR: " << e.argId() << std::endl + << " " << e.error() << std::endl << std::endl; + + if ( _cmd.hasHelpAndVersion() ) + { + std::cerr << "Brief USAGE: " << std::endl; + + _shortUsage( _cmd, std::cerr ); + + std::cerr << std::endl << "For complete USAGE and HELP type: " + << std::endl << " " << progName << " --help" + << std::endl << std::endl; + } + else + usage(_cmd); + + throw ExitException(1); +} + +inline void +StdOutput::_shortUsage( CmdLineInterface& _cmd, + std::ostream& os ) const +{ + std::list<Arg*> argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList(); + + std::string s = progName + " "; + + // first the xor + for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) + { + s += " {"; + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); it++ ) + s += (*it)->shortID() + "|"; + + s[s.length()-1] = '}'; + } + + // then the rest + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + s += " " + (*it)->shortID(); + + // if the program name is too long, then adjust the second line offset + int secondLineOffset = static_cast<int>(progName.length()) + 2; + if ( secondLineOffset > 75/2 ) + secondLineOffset = static_cast<int>(75/2); + + spacePrint( os, s, 75, 3, secondLineOffset ); +} + +inline void +StdOutput::_longUsage( CmdLineInterface& _cmd, + std::ostream& os ) const +{ + std::list<Arg*> argList = _cmd.getArgList(); + std::string message = _cmd.getMessage(); + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList(); + + // first the xor + for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) + { + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++ ) + { + spacePrint( os, (*it)->longID(), 75, 3, 3 ); + spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); + + if ( it+1 != xorList[i].end() ) + spacePrint(os, "-- OR --", 75, 9, 0); + } + os << std::endl << std::endl; + } + + // then the rest + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + if ( !xorHandler.contains( (*it) ) ) + { + spacePrint( os, (*it)->longID(), 75, 3, 3 ); + spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); + os << std::endl; + } + + os << std::endl; + + spacePrint( os, message, 75, 3, 0 ); +} + +inline void StdOutput::spacePrint( std::ostream& os, + const std::string& s, + int maxWidth, + int indentSpaces, + int secondLineOffset ) const +{ + int len = static_cast<int>(s.length()); + + if ( (len + indentSpaces > maxWidth) && maxWidth > 0 ) + { + int allowedLen = maxWidth - indentSpaces; + int start = 0; + while ( start < len ) + { + // find the substring length + // int stringLen = std::min<int>( len - start, allowedLen ); + // doing it this way to support a VisualC++ 2005 bug + using namespace std; + int stringLen = min<int>( len - start, allowedLen ); + + // trim the length so it doesn't end in middle of a word + if ( stringLen == allowedLen ) + while ( stringLen >= 0 && + s[stringLen+start] != ' ' && + s[stringLen+start] != ',' && + s[stringLen+start] != '|' ) + stringLen--; + + // ok, the word is longer than the line, so just split + // wherever the line ends + if ( stringLen <= 0 ) + stringLen = allowedLen; + + // check for newlines + for ( int i = 0; i < stringLen; i++ ) + if ( s[start+i] == '\n' ) + stringLen = i+1; + + // print the indent + for ( int i = 0; i < indentSpaces; i++ ) + os << " "; + + if ( start == 0 ) + { + // handle second line offsets + indentSpaces += secondLineOffset; + + // adjust allowed len + allowedLen -= secondLineOffset; + } + + os << s.substr(start,stringLen) << std::endl; + + // so we don't start a line with a space + while ( s[stringLen+start] == ' ' && start < len ) + start++; + + start += stringLen; + } + } + else + { + for ( int i = 0; i < indentSpaces; i++ ) + os << " "; + os << s << std::endl; + } +} + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLine.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLine.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/CmdLine.h (revision 921) @@ -0,0 +1,621 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: CmdLine.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CMDLINE_H +#define TCLAP_CMDLINE_H + +#include <tclap/SwitchArg.h> +#include <tclap/MultiSwitchArg.h> +#include <tclap/UnlabeledValueArg.h> +#include <tclap/UnlabeledMultiArg.h> + +#include <tclap/XorHandler.h> +#include <tclap/HelpVisitor.h> +#include <tclap/VersionVisitor.h> +#include <tclap/IgnoreRestVisitor.h> + +#include <tclap/CmdLineOutput.h> +#include <tclap/StdOutput.h> + +#include <tclap/Constraint.h> +#include <tclap/ValuesConstraint.h> + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <iomanip> +#include <algorithm> +#include <stdlib.h> // Needed for exit(), which isn't defined in some envs. + +namespace TCLAP { + +template<typename T> void DelPtr(T ptr) +{ + delete ptr; +} + +template<typename C> void ClearContainer(C &c) +{ + typedef typename C::value_type value_type; + std::for_each(c.begin(), c.end(), DelPtr<value_type>); + c.clear(); +} + + +/** + * The base class that manages the command line definition and passes + * along the parsing to the appropriate Arg classes. + */ +class CmdLine : public CmdLineInterface +{ + protected: + + /** + * The list of arguments that will be tested against the + * command line. + */ + std::list<Arg*> _argList; + + /** + * The name of the program. Set to argv[0]. + */ + std::string _progName; + + /** + * A message used to describe the program. Used in the usage output. + */ + std::string _message; + + /** + * The version to be displayed with the --version switch. + */ + std::string _version; + + /** + * The number of arguments that are required to be present on + * the command line. This is set dynamically, based on the + * Args added to the CmdLine object. + */ + int _numRequired; + + /** + * The character that is used to separate the argument flag/name + * from the value. Defaults to ' ' (space). + */ + char _delimiter; + + /** + * The handler that manages xoring lists of args. + */ + XorHandler _xorHandler; + + /** + * A list of Args to be explicitly deleted when the destructor + * is called. At the moment, this only includes the three default + * Args. + */ + std::list<Arg*> _argDeleteOnExitList; + + /** + * A list of Visitors to be explicitly deleted when the destructor + * is called. At the moment, these are the Vistors created for the + * default Args. + */ + std::list<Visitor*> _visitorDeleteOnExitList; + + /** + * Object that handles all output for the CmdLine. + */ + CmdLineOutput* _output; + + /** + * Should CmdLine handle parsing exceptions internally? + */ + bool _handleExceptions; + + /** + * Throws an exception listing the missing args. + */ + void missingArgsException(); + + /** + * Checks whether a name/flag string matches entirely matches + * the Arg::blankChar. Used when multiple switches are combined + * into a single argument. + * \param s - The message to be used in the usage. + */ + bool _emptyCombined(const std::string& s); + + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Arg* ptr); + + /** + * Perform a delete ptr; operation on ptr when this object is deleted. + */ + void deleteOnExit(Visitor* ptr); + +private: + + /** + * Encapsulates the code common to the constructors + * (which is all of it). + */ + void _constructor(); + + + /** + * Is set to true when a user sets the output object. We use this so + * that we don't delete objects that are created outside of this lib. + */ + bool _userSetOutput; + + /** + * Whether or not to automatically create help and version switches. + */ + bool _helpAndVersion; + + public: + + /** + * Command line constructor. Defines how the arguments will be + * parsed. + * \param message - The message to be used in the usage + * output. + * \param delimiter - The character that is used to separate + * the argument flag/name from the value. Defaults to ' ' (space). + * \param version - The version number to be used in the + * --version switch. + * \param helpAndVersion - Whether or not to create the Help and + * Version switches. Defaults to true. + */ + CmdLine(const std::string& message, + const char delimiter = ' ', + const std::string& version = "none", + bool helpAndVersion = true); + + /** + * Deletes any resources allocated by a CmdLine object. + */ + virtual ~CmdLine(); + + /** + * Adds an argument to the list of arguments to be parsed. + * \param a - Argument to be added. + */ + void add( Arg& a ); + + /** + * An alternative add. Functionally identical. + * \param a - Argument to be added. + */ + void add( Arg* a ); + + /** + * Add two Args that will be xor'd. If this method is used, add does + * not need to be called. + * \param a - Argument to be added and xor'd. + * \param b - Argument to be added and xor'd. + */ + void xorAdd( Arg& a, Arg& b ); + + /** + * Add a list of Args that will be xor'd. If this method is used, + * add does not need to be called. + * \param xors - List of Args to be added and xor'd. + */ + void xorAdd( std::vector<Arg*>& xors ); + + /** + * Parses the command line. + * \param argc - Number of arguments. + * \param argv - Array of arguments. + */ + void parse(int argc, const char * const * argv); + + /** + * Parses the command line. + * \param args - A vector of strings representing the args. + * args[0] is still the program name. + */ + void parse(std::vector<std::string>& args); + + /** + * + */ + CmdLineOutput* getOutput(); + + /** + * + */ + void setOutput(CmdLineOutput* co); + + /** + * + */ + std::string& getVersion(); + + /** + * + */ + std::string& getProgramName(); + + /** + * + */ + std::list<Arg*>& getArgList(); + + /** + * + */ + XorHandler& getXorHandler(); + + /** + * + */ + char getDelimiter(); + + /** + * + */ + std::string& getMessage(); + + /** + * + */ + bool hasHelpAndVersion(); + + /** + * Disables or enables CmdLine's internal parsing exception handling. + * + * @param state Should CmdLine handle parsing exceptions internally? + */ + void setExceptionHandling(const bool state); + + /** + * Returns the current state of the internal exception handling. + * + * @retval true Parsing exceptions are handled internally. + * @retval false Parsing exceptions are propagated to the caller. + */ + bool getExceptionHandling() const; + + /** + * Allows the CmdLine object to be reused. + */ + void reset(); + +}; + + +/////////////////////////////////////////////////////////////////////////////// +//Begin CmdLine.cpp +/////////////////////////////////////////////////////////////////////////////// + +inline CmdLine::CmdLine(const std::string& m, + char delim, + const std::string& v, + bool help ) +: _progName("not_set_yet"), + _message(m), + _version(v), + _numRequired(0), + _delimiter(delim), + _handleExceptions(true), + _userSetOutput(false), + _helpAndVersion(help) +{ + _constructor(); +} + +inline CmdLine::~CmdLine() +{ + ClearContainer(_argDeleteOnExitList); + ClearContainer(_visitorDeleteOnExitList); + + if ( !_userSetOutput ) { + delete _output; + _output = 0; + } +} + +inline void CmdLine::_constructor() +{ + _output = new StdOutput; + + Arg::setDelimiter( _delimiter ); + + Visitor* v; + + if ( _helpAndVersion ) + { + v = new HelpVisitor( this, &_output ); + SwitchArg* help = new SwitchArg("h","help", + "Displays usage information and exits.", + false, v); + add( help ); + deleteOnExit(help); + deleteOnExit(v); + + v = new VersionVisitor( this, &_output ); + SwitchArg* vers = new SwitchArg("","version", + "Displays version information and exits.", + false, v); + add( vers ); + deleteOnExit(vers); + deleteOnExit(v); + } + + v = new IgnoreRestVisitor(); + SwitchArg* ignore = new SwitchArg(Arg::flagStartString(), + Arg::ignoreNameString(), + "Ignores the rest of the labeled arguments following this flag.", + false, v); + add( ignore ); + deleteOnExit(ignore); + deleteOnExit(v); +} + +inline void CmdLine::xorAdd( std::vector<Arg*>& ors ) +{ + _xorHandler.add( ors ); + + for (ArgVectorIterator it = ors.begin(); it != ors.end(); it++) + { + (*it)->forceRequired(); + (*it)->setRequireLabel( "OR required" ); + + add( *it ); + } +} + +inline void CmdLine::xorAdd( Arg& a, Arg& b ) +{ + std::vector<Arg*> ors; + ors.push_back( &a ); + ors.push_back( &b ); + xorAdd( ors ); +} + +inline void CmdLine::add( Arg& a ) +{ + add( &a ); +} + +inline void CmdLine::add( Arg* a ) +{ + for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ ) + if ( *a == *(*it) ) + throw( SpecificationException( + "Argument with same flag/name already exists!", + a->longID() ) ); + + a->addToList( _argList ); + + if ( a->isRequired() ) + _numRequired++; +} + + +inline void CmdLine::parse(int argc, const char * const * argv) +{ + // this step is necessary so that we have easy access to + // mutable strings. + std::vector<std::string> args; + for (int i = 0; i < argc; i++) + args.push_back(argv[i]); + + parse(args); +} + +inline void CmdLine::parse(std::vector<std::string>& args) +{ + bool shouldExit = false; + int estat = 0; + + try { + _progName = args.front(); + args.erase(args.begin()); + + int requiredCount = 0; + + for (int i = 0; static_cast<unsigned int>(i) < args.size(); i++) { + bool matched = false; + for (ArgListIterator it = _argList.begin(); + it != _argList.end(); it++) { + if ( (*it)->processArg( &i, args ) ) + { + requiredCount += _xorHandler.check( *it ); + matched = true; + break; + } + } + + // checks to see if the argument is an empty combined + // switch and if so, then we've actually matched it + if ( !matched && _emptyCombined( args[i] ) ) + matched = true; + + if ( !matched && !Arg::ignoreRest() ) + throw(CmdLineParseException("Couldn't find match " + "for argument", + args[i])); + } + + if ( requiredCount < _numRequired ) + missingArgsException(); + + if ( requiredCount > _numRequired ) + throw(CmdLineParseException("Too many arguments!")); + + } catch ( ArgException& e ) { + // If we're not handling the exceptions, rethrow. + if ( !_handleExceptions) { + throw; + } + + try { + _output->failure(*this,e); + } catch ( ExitException &ee ) { + estat = ee.getExitStatus(); + shouldExit = true; + } + } catch (ExitException &ee) { + // If we're not handling the exceptions, rethrow. + if ( !_handleExceptions) { + throw; + } + + estat = ee.getExitStatus(); + shouldExit = true; + } + + if (shouldExit) + exit(estat); +} + +inline bool CmdLine::_emptyCombined(const std::string& s) +{ + if ( s.length() > 0 && s[0] != Arg::flagStartChar() ) + return false; + + for ( int i = 1; static_cast<unsigned int>(i) < s.length(); i++ ) + if ( s[i] != Arg::blankChar() ) + return false; + + return true; +} + +inline void CmdLine::missingArgsException() +{ + int count = 0; + + std::string missingArgList; + for (ArgListIterator it = _argList.begin(); it != _argList.end(); it++) + { + if ( (*it)->isRequired() && !(*it)->isSet() ) + { + missingArgList += (*it)->getName(); + missingArgList += ", "; + count++; + } + } + missingArgList = missingArgList.substr(0,missingArgList.length()-2); + + std::string msg; + if ( count > 1 ) + msg = "Required arguments missing: "; + else + msg = "Required argument missing: "; + + msg += missingArgList; + + throw(CmdLineParseException(msg)); +} + +inline void CmdLine::deleteOnExit(Arg* ptr) +{ + _argDeleteOnExitList.push_back(ptr); +} + +inline void CmdLine::deleteOnExit(Visitor* ptr) +{ + _visitorDeleteOnExitList.push_back(ptr); +} + +inline CmdLineOutput* CmdLine::getOutput() +{ + return _output; +} + +inline void CmdLine::setOutput(CmdLineOutput* co) +{ + _userSetOutput = true; + _output = co; +} + +inline std::string& CmdLine::getVersion() +{ + return _version; +} + +inline std::string& CmdLine::getProgramName() +{ + return _progName; +} + +inline std::list<Arg*>& CmdLine::getArgList() +{ + return _argList; +} + +inline XorHandler& CmdLine::getXorHandler() +{ + return _xorHandler; +} + +inline char CmdLine::getDelimiter() +{ + return _delimiter; +} + +inline std::string& CmdLine::getMessage() +{ + return _message; +} + +inline bool CmdLine::hasHelpAndVersion() +{ + return _helpAndVersion; +} + +inline void CmdLine::setExceptionHandling(const bool state) +{ + _handleExceptions = state; +} + +inline bool CmdLine::getExceptionHandling() const +{ + return _handleExceptions; +} + +inline void CmdLine::reset() +{ + for( ArgListIterator it = _argList.begin(); it != _argList.end(); it++ ) + { + (*it)->reset(); + } + + _progName.clear(); +} + +/////////////////////////////////////////////////////////////////////////////// +//End CmdLine.cpp +/////////////////////////////////////////////////////////////////////////////// + + + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/OptionalUnlabeledTracker.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/OptionalUnlabeledTracker.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/OptionalUnlabeledTracker.h (revision 921) @@ -0,0 +1,62 @@ + + +/****************************************************************************** + * + * file: OptionalUnlabeledTracker.h + * + * Copyright (c) 2005, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H +#define TCLAP_OPTIONAL_UNLABELED_TRACKER_H + +#include <string> + +namespace TCLAP { + +class OptionalUnlabeledTracker +{ + + public: + + static void check( bool req, const std::string& argName ); + + static void gotOptional() { alreadyOptionalRef() = true; } + + static bool& alreadyOptional() { return alreadyOptionalRef(); } + + private: + + static bool& alreadyOptionalRef() { static bool ct = false; return ct; } +}; + + +inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) +{ + if ( OptionalUnlabeledTracker::alreadyOptional() ) + throw( SpecificationException( + "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", + argName ) ); + + if ( !req ) + OptionalUnlabeledTracker::gotOptional(); +} + + +} // namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ZshCompletionOutput.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ZshCompletionOutput.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ZshCompletionOutput.h (revision 921) @@ -0,0 +1,321 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ZshCompletionOutput.h + * + * Copyright (c) 2006, Oliver Kiddle + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H +#define TCLAP_ZSHCOMPLETIONOUTPUT_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <map> + +#include <tclap/CmdLineInterface.h> +#include <tclap/CmdLineOutput.h> +#include <tclap/XorHandler.h> +#include <tclap/Arg.h> + +namespace TCLAP { + +/** + * A class that generates a Zsh completion function as output from the usage() + * method for the given CmdLine and its Args. + */ +class ZshCompletionOutput : public CmdLineOutput +{ + + public: + + ZshCompletionOutput(); + + /** + * Prints the usage to stdout. Can be overridden to + * produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void usage(CmdLineInterface& c); + + /** + * Prints the version to stdout. Can be overridden + * to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + */ + virtual void version(CmdLineInterface& c); + + /** + * Prints (to stderr) an error message, short usage + * Can be overridden to produce alternative behavior. + * \param c - The CmdLine object the output is generated for. + * \param e - The ArgException that caused the failure. + */ + virtual void failure(CmdLineInterface& c, + ArgException& e ); + + protected: + + void basename( std::string& s ); + void quoteSpecialChars( std::string& s ); + + std::string getMutexList( CmdLineInterface& _cmd, Arg* a ); + void printOption( Arg* it, std::string mutex ); + void printArg( Arg* it ); + + std::map<std::string, std::string> common; + char theDelimiter; +}; + +ZshCompletionOutput::ZshCompletionOutput() +{ + common["host"] = "_hosts"; + common["hostname"] = "_hosts"; + common["file"] = "_files"; + common["filename"] = "_files"; + common["user"] = "_users"; + common["username"] = "_users"; + common["directory"] = "_directories"; + common["path"] = "_directories"; + common["url"] = "_urls"; +} + +inline void ZshCompletionOutput::version(CmdLineInterface& _cmd) +{ + std::cout << _cmd.getVersion() << std::endl; +} + +inline void ZshCompletionOutput::usage(CmdLineInterface& _cmd ) +{ + std::list<Arg*> argList = _cmd.getArgList(); + std::string progName = _cmd.getProgramName(); + std::string version = _cmd.getVersion(); + theDelimiter = _cmd.getDelimiter(); + basename(progName); + + std::cout << "#compdef " << progName << std::endl << std::endl << + "# " << progName << " version " << _cmd.getVersion() << std::endl << std::endl << + "_arguments -s -S"; + + for (ArgListIterator it = argList.begin(); it != argList.end(); it++) + { + if ( (*it)->shortID().at(0) == '<' ) + printArg((*it)); + else if ( (*it)->getFlag() != "-" ) + printOption((*it), getMutexList(_cmd, *it)); + } + + std::cout << std::endl; +} + +inline void ZshCompletionOutput::failure( CmdLineInterface& _cmd, + ArgException& e ) +{ + static_cast<void>(_cmd); // unused + std::cout << e.what() << std::endl; +} + +inline void ZshCompletionOutput::quoteSpecialChars( std::string& s ) +{ + size_t idx = s.find_last_of(':'); + while ( idx != std::string::npos ) + { + s.insert(idx, 1, '\\'); + idx = s.find_last_of(':', idx); + } + idx = s.find_last_of('\''); + while ( idx != std::string::npos ) + { + s.insert(idx, "'\\'"); + if (idx == 0) + idx = std::string::npos; + else + idx = s.find_last_of('\'', --idx); + } +} + +inline void ZshCompletionOutput::basename( std::string& s ) +{ + size_t p = s.find_last_of('/'); + if ( p != std::string::npos ) + { + s.erase(0, p + 1); + } +} + +inline void ZshCompletionOutput::printArg(Arg* a) +{ + static int count = 1; + + std::cout << " \\" << std::endl << " '"; + if ( a->acceptsMultipleValues() ) + std::cout << '*'; + else + std::cout << count++; + std::cout << ':'; + if ( !a->isRequired() ) + std::cout << ':'; + + std::cout << a->getName() << ':'; + std::map<std::string, std::string>::iterator compArg = common.find(a->getName()); + if ( compArg != common.end() ) + { + std::cout << compArg->second; + } + else + { + std::cout << "_guard \"^-*\" " << a->getName(); + } + std::cout << '\''; +} + +inline void ZshCompletionOutput::printOption(Arg* a, std::string mutex) +{ + std::string flag = a->flagStartChar() + a->getFlag(); + std::string name = a->nameStartString() + a->getName(); + std::string desc = a->getDescription(); + + // remove full stop and capitalisation from description as + // this is the convention for zsh function + if (!desc.compare(0, 12, "(required) ")) + { + desc.erase(0, 12); + } + if (!desc.compare(0, 15, "(OR required) ")) + { + desc.erase(0, 15); + } + size_t len = desc.length(); + if (len && desc.at(--len) == '.') + { + desc.erase(len); + } + if (len) + { + desc.replace(0, 1, 1, tolower(desc.at(0))); + } + + std::cout << " \\" << std::endl << " '" << mutex; + + if ( a->getFlag().empty() ) + { + std::cout << name; + } + else + { + std::cout << "'{" << flag << ',' << name << "}'"; + } + if ( theDelimiter == '=' && a->isValueRequired() ) + std::cout << "=-"; + quoteSpecialChars(desc); + std::cout << '[' << desc << ']'; + + if ( a->isValueRequired() ) + { + std::string arg = a->shortID(); + arg.erase(0, arg.find_last_of(theDelimiter) + 1); + if ( arg.at(arg.length()-1) == ']' ) + arg.erase(arg.length()-1); + if ( arg.at(arg.length()-1) == ']' ) + { + arg.erase(arg.length()-1); + } + if ( arg.at(0) == '<' ) + { + arg.erase(arg.length()-1); + arg.erase(0, 1); + } + size_t p = arg.find('|'); + if ( p != std::string::npos ) + { + do + { + arg.replace(p, 1, 1, ' '); + } + while ( (p = arg.find_first_of('|', p)) != std::string::npos ); + quoteSpecialChars(arg); + std::cout << ": :(" << arg << ')'; + } + else + { + std::cout << ':' << arg; + std::map<std::string, std::string>::iterator compArg = common.find(arg); + if ( compArg != common.end() ) + { + std::cout << ':' << compArg->second; + } + } + } + + std::cout << '\''; +} + +inline std::string ZshCompletionOutput::getMutexList( CmdLineInterface& _cmd, Arg* a) +{ + XorHandler xorHandler = _cmd.getXorHandler(); + std::vector< std::vector<Arg*> > xorList = xorHandler.getXorList(); + + if (a->getName() == "help" || a->getName() == "version") + { + return "(-)"; + } + + std::ostringstream list; + if ( a->acceptsMultipleValues() ) + { + list << '*'; + } + + for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) + { + for ( ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++) + if ( a == (*it) ) + { + list << '('; + for ( ArgVectorIterator iu = xorList[i].begin(); + iu != xorList[i].end(); + iu++ ) + { + bool notCur = (*iu) != a; + bool hasFlag = !(*iu)->getFlag().empty(); + if ( iu != xorList[i].begin() && (notCur || hasFlag) ) + list << ' '; + if (hasFlag) + list << (*iu)->flagStartChar() << (*iu)->getFlag() << ' '; + if ( notCur || hasFlag ) + list << (*iu)->nameStartString() << (*iu)->getName(); + } + list << ')'; + return list.str(); + } + } + + // wasn't found in xor list + if (!a->getFlag().empty()) { + list << "(" << a->flagStartChar() << a->getFlag() << ' ' << + a->nameStartString() << a->getName() << ')'; + } + + return list.str(); +} + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledValueArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledValueArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/UnlabeledValueArg.h (revision 921) @@ -0,0 +1,340 @@ + +/****************************************************************************** + * + * file: UnlabeledValueArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_UNLABELED_VALUE_ARGUMENT_H +#define TCLAP_UNLABELED_VALUE_ARGUMENT_H + +#include <string> +#include <vector> + +#include <tclap/ValueArg.h> +#include <tclap/OptionalUnlabeledTracker.h> + + +namespace TCLAP { + +/** + * The basic unlabeled argument that parses a value. + * This is a template class, which means the type T defines the type + * that a given object will attempt to parse when an UnlabeledValueArg + * is reached in the list of args that the CmdLine iterates over. + */ +template<class T> +class UnlabeledValueArg : public ValueArg<T> +{ + + // If compiler has two stage name lookup (as gcc >= 3.4 does) + // this is requried to prevent undef. symbols + using ValueArg<T>::_ignoreable; + using ValueArg<T>::_hasBlanks; + using ValueArg<T>::_extractValue; + using ValueArg<T>::_typeDesc; + using ValueArg<T>::_name; + using ValueArg<T>::_description; + using ValueArg<T>::_alreadySet; + using ValueArg<T>::toString; + + public: + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Vistor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + bool ignoreable = false, + Visitor* v = NULL); + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Vistor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL ); + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Vistor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint<T>* constraint, + bool ignoreable = false, + Visitor* v = NULL ); + + + /** + * UnlabeledValueArg constructor. + * \param name - A one word name for the argument. Note that this is used for + * identification, not as a long flag. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param value - The default value assigned to this argument if it + * is not present on the command line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param ignoreable - Allows you to specify that this argument can be + * ignored if the '--' flag is set. This defaults to false (cannot + * be ignored) and should generally stay that way unless you have + * some special need for certain arguments to be ignored. + * \param v - Optional Vistor. You should leave this blank unless + * you have a very good reason. + */ + UnlabeledValueArg( const std::string& name, + const std::string& desc, + bool req, + T value, + Constraint<T>* constraint, + CmdLineInterface& parser, + bool ignoreable = false, + Visitor* v = NULL); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. Handling specific to + * unlabled arguments. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Overrides shortID for specific behavior. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Overrides longID for specific behavior. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Overrides operator== for specific behavior. + */ + virtual bool operator==(const Arg& a ) const; + + /** + * Instead of pushing to the front of list, push to the back. + * \param argList - The list to add this to. + */ + virtual void addToList( std::list<Arg*>& argList ) const; + +}; + +/** + * Constructor implemenation. + */ +template<class T> +UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + bool ignoreable, + Visitor* v) +: ValueArg<T>("", name, desc, req, val, typeDesc, v) +{ + _ignoreable = ignoreable; + + OptionalUnlabeledTracker::check(req, toString()); + +} + +template<class T> +UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + const std::string& typeDesc, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: ValueArg<T>("", name, desc, req, val, typeDesc, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); + parser.add( this ); +} + +/** + * Constructor implemenation. + */ +template<class T> +UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint<T>* constraint, + bool ignoreable, + Visitor* v) +: ValueArg<T>("", name, desc, req, val, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); +} + +template<class T> +UnlabeledValueArg<T>::UnlabeledValueArg(const std::string& name, + const std::string& desc, + bool req, + T val, + Constraint<T>* constraint, + CmdLineInterface& parser, + bool ignoreable, + Visitor* v) +: ValueArg<T>("", name, desc, req, val, constraint, v) +{ + _ignoreable = ignoreable; + OptionalUnlabeledTracker::check(req, toString()); + parser.add( this ); +} + +/** + * Implementation of processArg(). + */ +template<class T> +bool UnlabeledValueArg<T>::processArg(int *i, std::vector<std::string>& args) +{ + + if ( _alreadySet ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + // never ignore an unlabeled arg + + _extractValue( args[*i] ); + _alreadySet = true; + return true; +} + +/** + * Overriding shortID for specific output. + */ +template<class T> +std::string UnlabeledValueArg<T>::shortID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return std::string("<") + _typeDesc + ">"; +} + +/** + * Overriding longID for specific output. + */ +template<class T> +std::string UnlabeledValueArg<T>::longID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + + // Ideally we would like to be able to use RTTI to return the name + // of the type required for this argument. However, g++ at least, + // doesn't appear to return terribly useful "names" of the types. + return std::string("<") + _typeDesc + ">"; +} + +/** + * Overriding operator== for specific behavior. + */ +template<class T> +bool UnlabeledValueArg<T>::operator==(const Arg& a ) const +{ + if ( _name == a.getName() || _description == a.getDescription() ) + return true; + else + return false; +} + +template<class T> +void UnlabeledValueArg<T>::addToList( std::list<Arg*>& argList ) const +{ + argList.push_back( const_cast<Arg*>(static_cast<const Arg* const>(this)) ); +} + +} +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Makefile.am (revision 921) @@ -0,0 +1,29 @@ +SUBDIRS = . + +libtclapincludedir = $(includedir)/tclap + +dist_noinst_HEADERS = \ + CmdLineInterface.h \ + ArgException.h \ + CmdLine.h \ + XorHandler.h \ + MultiArg.h \ + UnlabeledMultiArg.h \ + ValueArg.h \ + UnlabeledValueArg.h \ + Visitor.h Arg.h \ + HelpVisitor.h \ + SwitchArg.h \ + MultiSwitchArg.h \ + VersionVisitor.h \ + IgnoreRestVisitor.h \ + CmdLineOutput.h \ + StdOutput.h \ + DocBookOutput.h \ + ZshCompletionOutput.h \ + OptionalUnlabeledTracker.h \ + Constraint.h \ + ValuesConstraint.h \ + ArgTraits.h \ + StandardTraits.h + Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Constraint.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Constraint.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/Constraint.h (revision 921) @@ -0,0 +1,68 @@ + +/****************************************************************************** + * + * file: Constraint.h + * + * Copyright (c) 2005, Michael E. Smoot + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +#ifndef TCLAP_CONSTRAINT_H +#define TCLAP_CONSTRAINT_H + +#include <string> +#include <vector> +#include <list> +#include <iostream> +#include <iomanip> +#include <algorithm> + +namespace TCLAP { + +/** + * The interface that defines the interaction between the Arg and Constraint. + */ +template<class T> +class Constraint +{ + + public: + /** + * Returns a description of the Constraint. + */ + virtual std::string description() const =0; + + /** + * Returns the short ID for the Constraint. + */ + virtual std::string shortID() const =0; + + /** + * The method used to verify that the value parsed from the command + * line meets the constraint. + * \param value - The value that will be checked. + */ + virtual bool check(const T& value) const =0; + + /** + * Destructor. + * Silences warnings about Constraint being a base class with virtual + * functions but without a virtual destructor. + */ + virtual ~Constraint() { ; } +}; + +} //namespace TCLAP +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiArg.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiArg.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/MultiArg.h (revision 921) @@ -0,0 +1,422 @@ +/****************************************************************************** + * + * file: MultiArg.h + * + * Copyright (c) 2003, Michael E. Smoot . + * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno. + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_MULTIPLE_ARGUMENT_H +#define TCLAP_MULTIPLE_ARGUMENT_H + +#include <string> +#include <vector> + +#include <tclap/Arg.h> +#include <tclap/Constraint.h> + +namespace TCLAP { +/** + * An argument that allows multiple values of type T to be specified. Very + * similar to a ValueArg, except a vector of values will be returned + * instead of just one. + */ +template<class T> +class MultiArg : public Arg +{ +public: + typedef std::vector<T> container_type; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + +protected: + + /** + * The list of values parsed from the CmdLine. + */ + std::vector<T> _values; + + /** + * The description of type T to be used in the usage. + */ + std::string _typeDesc; + + /** + * A list of constraint on this Arg. + */ + Constraint<T>* _constraint; + + /** + * Extracts the value from the string. + * Attempts to parse string as type T, if this fails an exception + * is thrown. + * \param val - The string to be read. + */ + void _extractValue( const std::string& val ); + + /** + * Used by XorHandler to decide whether to keep parsing for this arg. + */ + bool _allowMore; + +public: + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + Visitor* v = NULL); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param typeDesc - A short, human readable description of the + * type that this object expects. This is used in the generation + * of the USAGE statement. The goal is to be helpful to the end user + * of the program. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + Visitor* v = NULL ); + + /** + * Constructor. + * \param flag - The one character flag that identifies this + * argument on the command line. + * \param name - A one word name for the argument. Can be + * used as a long flag on the command line. + * \param desc - A description of what the argument is for or + * does. + * \param req - Whether the argument is required on the command + * line. + * \param constraint - A pointer to a Constraint object used + * to constrain this Arg. + * \param parser - A CmdLine parser object to add this Arg to + * \param v - An optional visitor. You probably should not + * use this unless you have a very good reason. + */ + MultiArg( const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + CmdLineInterface& parser, + Visitor* v = NULL ); + + /** + * Handles the processing of the argument. + * This re-implements the Arg version of this method to set the + * _value of the argument appropriately. It knows the difference + * between labeled and unlabeled. + * \param i - Pointer the the current argument in the list. + * \param args - Mutable list of strings. Passed from main(). + */ + virtual bool processArg(int* i, std::vector<std::string>& args); + + /** + * Returns a vector of type T containing the values parsed from + * the command line. + */ + const std::vector<T>& getValue(); + + /** + * Returns an iterator over the values parsed from the command + * line. + */ + const_iterator begin() const { return _values.begin(); } + + /** + * Returns the end of the values parsed from the command + * line. + */ + const_iterator end() const { return _values.end(); } + + /** + * Returns the a short id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string shortID(const std::string& val="val") const; + + /** + * Returns the a long id string. Used in the usage. + * \param val - value to be used. + */ + virtual std::string longID(const std::string& val="val") const; + + /** + * Once we've matched the first value, then the arg is no longer + * required. + */ + virtual bool isRequired() const; + + virtual bool allowMore(); + + virtual void reset(); + +}; + +template<class T> +MultiArg<T>::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _typeDesc( typeDesc ), + _constraint( NULL ), + _allowMore(false) +{ + _acceptsMultipleValues = true; +} + +template<class T> +MultiArg<T>::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + const std::string& typeDesc, + CmdLineInterface& parser, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _typeDesc( typeDesc ), + _constraint( NULL ), + _allowMore(false) +{ + parser.add( this ); + _acceptsMultipleValues = true; +} + +/** + * + */ +template<class T> +MultiArg<T>::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _typeDesc( constraint->shortID() ), + _constraint( constraint ), + _allowMore(false) +{ + _acceptsMultipleValues = true; +} + +template<class T> +MultiArg<T>::MultiArg(const std::string& flag, + const std::string& name, + const std::string& desc, + bool req, + Constraint<T>* constraint, + CmdLineInterface& parser, + Visitor* v) +: Arg( flag, name, desc, req, true, v ), + _typeDesc( constraint->shortID() ), + _constraint( constraint ), + _allowMore(false) +{ + parser.add( this ); + _acceptsMultipleValues = true; +} + +template<class T> +const std::vector<T>& MultiArg<T>::getValue() { return _values; } + +template<class T> +bool MultiArg<T>::processArg(int *i, std::vector<std::string>& args) +{ + if ( _ignoreable && Arg::ignoreRest() ) + return false; + + if ( _hasBlanks( args[*i] ) ) + return false; + + std::string flag = args[*i]; + std::string value = ""; + + trimFlag( flag, value ); + + if ( argMatches( flag ) ) + { + if ( Arg::delimiter() != ' ' && value == "" ) + throw( ArgParseException( + "Couldn't find delimiter for this argument!", + toString() ) ); + + // always take the first one, regardless of start string + if ( value == "" ) + { + (*i)++; + if ( static_cast<unsigned int>(*i) < args.size() ) + _extractValue( args[*i] ); + else + throw( ArgParseException("Missing a value for this argument!", + toString() ) ); + } + else + _extractValue( value ); + + /* + // continuing taking the args until we hit one with a start string + while ( (unsigned int)(*i)+1 < args.size() && + args[(*i)+1].find_first_of( Arg::flagStartString() ) != 0 && + args[(*i)+1].find_first_of( Arg::nameStartString() ) != 0 ) + _extractValue( args[++(*i)] ); + */ + + _alreadySet = true; + _checkWithVisitor(); + + return true; + } + else + return false; +} + +/** + * + */ +template<class T> +std::string MultiArg<T>::shortID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return Arg::shortID(_typeDesc) + " ... "; +} + +/** + * + */ +template<class T> +std::string MultiArg<T>::longID(const std::string& val) const +{ + static_cast<void>(val); // Ignore input, don't warn + return Arg::longID(_typeDesc) + " (accepted multiple times)"; +} + +/** + * Once we've matched the first value, then the arg is no longer + * required. + */ +template<class T> +bool MultiArg<T>::isRequired() const +{ + if ( _required ) + { + if ( _values.size() > 1 ) + return false; + else + return true; + } + else + return false; + +} + +template<class T> +void MultiArg<T>::_extractValue( const std::string& val ) +{ + try { + T tmp; + ExtractValue(tmp, val, typename ArgTraits<T>::ValueCategory()); + _values.push_back(tmp); + } catch( ArgParseException &e) { + throw ArgParseException(e.error(), toString()); + } + + if ( _constraint != NULL ) + if ( ! _constraint->check( _values.back() ) ) + throw( CmdLineParseException( "Value '" + val + + "' does not meet constraint: " + + _constraint->description(), + toString() ) ); +} + +template<class T> +bool MultiArg<T>::allowMore() +{ + bool am = _allowMore; + _allowMore = true; + return am; +} + +template<class T> +void MultiArg<T>::reset() +{ + Arg::reset(); + _values.clear(); +} + +} // namespace TCLAP + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StandardTraits.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StandardTraits.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/StandardTraits.h (revision 921) @@ -0,0 +1,184 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: StandardTraits.h + * + * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + +// This is an internal tclap file, you should probably not have to +// include this directly + +#ifndef TCLAP_STANDARD_TRAITS_H +#define TCLAP_STANDARD_TRAITS_H + +#ifdef HAVE_CONFIG_H +#include <config.h> // To check for long long +#endif + +namespace TCLAP { + +// ====================================================================== +// Integer types +// ====================================================================== + +/** + * longs have value-like semantics. + */ +template<> +struct ArgTraits<long> { + typedef ValueLike ValueCategory; +}; + +/** + * ints have value-like semantics. + */ +template<> +struct ArgTraits<int> { + typedef ValueLike ValueCategory; +}; + +/** + * shorts have value-like semantics. + */ +template<> +struct ArgTraits<short> { + typedef ValueLike ValueCategory; +}; + +/** + * chars have value-like semantics. + */ +template<> +struct ArgTraits<char> { + typedef ValueLike ValueCategory; +}; + +#ifdef HAVE_LONG_LONG +/** + * long longs have value-like semantics. + */ +template<> +struct ArgTraits<long long> { + typedef ValueLike ValueCategory; +}; +#endif + +// ====================================================================== +// Unsigned integer types +// ====================================================================== + +/** + * unsigned longs have value-like semantics. + */ +template<> +struct ArgTraits<unsigned long> { + typedef ValueLike ValueCategory; +}; + +/** + * unsigned ints have value-like semantics. + */ +template<> +struct ArgTraits<unsigned int> { + typedef ValueLike ValueCategory; +}; + +/** + * unsigned shorts have value-like semantics. + */ +template<> +struct ArgTraits<unsigned short> { + typedef ValueLike ValueCategory; +}; + +/** + * unsigned chars have value-like semantics. + */ +template<> +struct ArgTraits<unsigned char> { + typedef ValueLike ValueCategory; +}; + +#ifdef HAVE_LONG_LONG +/** + * unsigned long longs have value-like semantics. + */ +template<> +struct ArgTraits<unsigned long long> { + typedef ValueLike ValueCategory; +}; +#endif + +// ====================================================================== +// Float types +// ====================================================================== + +/** + * floats have value-like semantics. + */ +template<> +struct ArgTraits<float> { + typedef ValueLike ValueCategory; +}; + +/** + * doubles have value-like semantics. + */ +template<> +struct ArgTraits<double> { + typedef ValueLike ValueCategory; +}; + +// ====================================================================== +// Other types +// ====================================================================== + +/** + * bools have value-like semantics. + */ +template<> +struct ArgTraits<bool> { + typedef ValueLike ValueCategory; +}; + +/** + * wchar_ts have value-like semantics. + */ +template<> +struct ArgTraits<wchar_t> { + typedef ValueLike ValueCategory; +}; + +/** + * Strings have string like argument traits. + */ +template<> +struct ArgTraits<std::string> { + typedef StringLike ValueCategory; +}; + +template<typename T> +void SetString(T &dst, const std::string &src) +{ + dst = src; +} + +} // namespace + +#endif + Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgException.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgException.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap/ArgException.h (revision 921) @@ -0,0 +1,200 @@ +// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- + +/****************************************************************************** + * + * file: ArgException.h + * + * Copyright (c) 2003, Michael E. Smoot . + * All rights reverved. + * + * See the file COPYING in the top directory of this distribution for + * more information. + * + * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + *****************************************************************************/ + + +#ifndef TCLAP_ARG_EXCEPTION_H +#define TCLAP_ARG_EXCEPTION_H + +#include <string> +#include <exception> + +namespace TCLAP { + +/** + * A simple class that defines and argument exception. Should be caught + * whenever a CmdLine is created and parsed. + */ +class ArgException : public std::exception +{ + public: + + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source. + * \param td - Text describing the type of ArgException it is. + * of the exception. + */ + ArgException( const std::string& text = "undefined exception", + const std::string& id = "undefined", + const std::string& td = "Generic ArgException") + : std::exception(), + _errorText(text), + _argId( id ), + _typeDescription(td) + { } + + /** + * Destructor. + */ + virtual ~ArgException() throw() { } + + /** + * Returns the error text. + */ + std::string error() const { return ( _errorText ); } + + /** + * Returns the argument id. + */ + std::string argId() const + { + if ( _argId == "undefined" ) + return " "; + else + return ( "Argument: " + _argId ); + } + + /** + * Returns the arg id and error text. + */ + const char* what() const throw() + { + static std::string ex; + ex = _argId + " -- " + _errorText; + return ex.c_str(); + } + + /** + * Returns the type of the exception. Used to explain and distinguish + * between different child exceptions. + */ + std::string typeDescription() const + { + return _typeDescription; + } + + + private: + + /** + * The text of the exception message. + */ + std::string _errorText; + + /** + * The argument related to this exception. + */ + std::string _argId; + + /** + * Describes the type of the exception. Used to distinguish + * between different child exceptions. + */ + std::string _typeDescription; + +}; + +/** + * Thrown from within the child Arg classes when it fails to properly + * parse the argument it has been passed. + */ +class ArgParseException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + ArgParseException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string( "Exception found while parsing " ) + + std::string( "the value the Arg has been passed." )) + { } +}; + +/** + * Thrown from CmdLine when the arguments on the command line are not + * properly specified, e.g. too many arguments, required argument missing, etc. + */ +class CmdLineParseException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + CmdLineParseException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string( "Exception found when the values ") + + std::string( "on the command line do not meet ") + + std::string( "the requirements of the defined ") + + std::string( "Args." )) + { } +}; + +/** + * Thrown from Arg and CmdLine when an Arg is improperly specified, e.g. + * same flag as another Arg, same name, etc. + */ +class SpecificationException : public ArgException +{ + public: + /** + * Constructor. + * \param text - The text of the exception. + * \param id - The text identifying the argument source + * of the exception. + */ + SpecificationException( const std::string& text = "undefined exception", + const std::string& id = "undefined" ) + : ArgException( text, + id, + std::string("Exception found when an Arg object ")+ + std::string("is improperly defined by the ") + + std::string("developer." )) + { } + +}; + +class ExitException { +public: + ExitException(int estat) : _estat(estat) {} + + int getExitStatus() const { return _estat; } + +private: + int _estat; +}; + +} // namespace TCLAP + +#endif + Index: tags/Sacrifice-1.1.1/Sacrifice/include/tclap =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/tclap (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/include/tclap (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/include/tclap ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,4 ## +Makefile +Makefile.in +*~ +._* Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Utils.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Utils.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Utils.hh (revision 921) @@ -0,0 +1,43 @@ +#ifndef SACRIFICE_UTILS_HH +#define SACRIFICE_UTILS_HH + +#include "Sacrifice/binreloc.h" + +#include <string> +#include <vector> +#include <fstream> + +namespace Sacrifice{ + + using std::string; + using std::vector; + using std::ifstream; + + string findParamFile(const string &filename){ + +// BrInitError brError; +// br_init_lib(&brError); + string path = br_find_data_dir(DEFAULTPARAMDIR); + + vector<string> toCheck; + toCheck.push_back(filename); + toCheck.push_back(filename + ".params"); + if(path != ""){ + toCheck.push_back(path + "/" + filename); + toCheck.push_back(path + "/" + filename + ".params"); + } + vector<string>::const_iterator file = toCheck.begin(); + + while(file != toCheck.end()){ + + ifstream testFile(file->c_str(), ifstream::in); + if(testFile.is_open()) break; + ++file; + } + + path = (file == toCheck.end())? filename: *file; + return path; + } + +} +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Exceptions.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Exceptions.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Exceptions.hh (revision 921) @@ -0,0 +1,42 @@ +#ifndef SACRIFICE_EXCEPTIONS_HH +#define SACRIFICE_EXCEPTIONS_HH + +#include <stdexcept> +#include <sstream> +#include <iostream> +#include <string> + +namespace Sacrifice{ + + using std::string; + using std::stringstream; + + class PhotosException: public std::runtime_error{ + + public: + + PhotosException(): std::runtime_error(PhotosException::errMessage()){}; + + private: + static string errMessage(){ + static stringstream ss; + ss << "Photos requested, but support missing. Problems: "<<std::endl; + +#ifndef HAS_PHOTOS + ss << " Photos++ library not linked"<<std::endl; +#endif + +#ifndef HAS_HEPMC + ss << " HepMC not available" << std::endl; +#else +#ifndef HEPMC_HAS_UNITS + ss << " HepMC does not provide units support" <<std::endl; +#endif +#endif + return ss.str(); + } + }; + +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/HepMCIOHandler.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/HepMCIOHandler.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/HepMCIOHandler.hh (revision 921) @@ -0,0 +1,63 @@ +#ifndef SACRIFICE_HEPMCIO_HANDLER_HH +#define SACRIFICE_HEPMCIO_HANDLER_HH + +#include "tclap/CmdLine.h" + +#include "HepMC/IO_GenEvent.h" + +#include <string> +#include <fstream> +#include <memory> + +namespace Sacrifice{ + + using std::string; + using std::ostream; + using std::unique_ptr; + + using TCLAP::SwitchArg; + using TCLAP::ValueArg; + + class HepMCIOHandler{ + + public: + + HepMCIOHandler(TCLAP::CmdLine &cmd); + + ~HepMCIOHandler(){ + //m_io.reset(); + //m_ostr.reset(); + //m_zippedStream.reset(); + + } + + void writeEvent(const HepMC::GenEvent *event){ + + if(m_doInitialise)initialise(); + + (*m_io) << event; + + return; + } + + private: + + void initialise(); + + bool m_doInitialise; + + unique_ptr<ostream> m_ostr; + + unique_ptr<ostream> m_zippedStream; + + unique_ptr<HepMC::IO_GenEvent> m_io; + + // Switch to turn on gzip compression + SwitchArg m_zipArg; + + ValueArg<string> m_outputArg; + + }; +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/binreloc.h =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/binreloc.h (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/binreloc.h (revision 921) @@ -0,0 +1,81 @@ +/* + * BinReloc - a library for creating relocatable executables + * Written by: Hongli Lai <h.lai@chello.nl> + * http://autopackage.org/ + * + * This source code is public domain. You can relicense this code + * under whatever license you want. + * + * See http://autopackage.org/docs/binreloc/ for + * more information and how to use this. + */ + +#ifndef __BINRELOC_H__ +#define __BINRELOC_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib(). */ +typedef enum { + /** Cannot allocate memory. */ + BR_INIT_ERROR_NOMEM, + /** Unable to open /proc/self/maps; see errno for details. */ + BR_INIT_ERROR_OPEN_MAPS, + /** Unable to read from /proc/self/maps; see errno for details. */ + BR_INIT_ERROR_READ_MAPS, + /** The file format of /proc/self/maps is invalid; kernel bug? */ + BR_INIT_ERROR_INVALID_MAPS, + /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */ + BR_INIT_ERROR_DISABLED +} BrInitError; + + +#ifndef BINRELOC_RUNNING_DOXYGEN + /* Mangle symbol names to avoid symbol + * collisions with other ELF objects. + */ + #define br_init xxji25564111619049_br_init + #define br_init_lib xxji25564111619049_br_init_lib + #define br_find_exe xxji25564111619049_br_find_exe + #define br_find_exe_dir xxji25564111619049_br_find_exe_dir + #define br_find_prefix xxji25564111619049_br_find_prefix + #define br_find_bin_dir xxji25564111619049_br_find_bin_dir + #define br_find_sbin_dir xxji25564111619049_br_find_sbin_dir + #define br_find_data_dir xxji25564111619049_br_find_data_dir + #define br_find_locale_dir xxji25564111619049_br_find_locale_dir + #define br_find_lib_dir xxji25564111619049_br_find_lib_dir + #define br_find_libexec_dir xxji25564111619049_br_find_libexec_dir + #define br_find_etc_dir xxji25564111619049_br_find_etc_dir + #define br_strcat xxji25564111619049_br_strcat + #define br_build_path xxji25564111619049_br_build_path + #define br_dirname xxji25564111619049_br_dirname +#endif + +int br_init (BrInitError *error); +int br_init_lib (BrInitError *error); + +char *br_find_exe (const char *default_exe); +char *br_find_exe_dir (const char *default_dir); +char *br_find_prefix (const char *default_prefix); +char *br_find_bin_dir (const char *default_bin_dir); +char *br_find_sbin_dir (const char *default_sbin_dir); +char *br_find_data_dir (const char *default_data_dir); +char *br_find_locale_dir (const char *default_locale_dir); +char *br_find_lib_dir (const char *default_lib_dir); +char *br_find_libexec_dir (const char *default_libexec_dir); +char *br_find_etc_dir (const char *default_etc_dir); + +/* Utility functions */ +char *br_strcat (const char *str1, const char *str2); +char *br_build_path (const char *dir, const char *file); +char *br_dirname (const char *path); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __BINRELOC_H__ */ Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/BeamParticle.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/BeamParticle.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/BeamParticle.hh (revision 921) @@ -0,0 +1,46 @@ +#ifndef SACRIFICE_BEAMPARTICLE_HH +#define SACRIFICE_BEAMPARTICLE_HH + +#include <string> +#include <map> + +namespace Sacrifice{ + + class BeamParticle{ + + public: + + enum PDGID {PROTON=2212, ANTIPROTON=-2212, ELECTRON=11, POSITRON=-11, INVALID=0}; + + BeamParticle(const std::string &name){ + + std::map<std::string, PDGID>::const_iterator it = s_particleIDs().find(name); + if(it == s_particleIDs().end()){ + m_id = INVALID; + m_name = "INVALID"; + }else{ + m_id = it->second; + m_name = name; + } + } + + PDGID asID()const{ + return m_id; + } + + const std::string &asString()const{ + return m_name; + } + + private: + + static std::map<std::string, PDGID> &s_particleIDs(); + static bool s_init; + + PDGID m_id; + std::string m_name; + + }; +} + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/PhotosHandler.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/PhotosHandler.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/PhotosHandler.hh (revision 921) @@ -0,0 +1,63 @@ +#ifndef SACRIFICE_PHOTOSHANDLER_HH +#define SACRIFICE_PHOTOSHANDLER_HH + +#include "tclap/CmdLine.h" + +namespace HepMC{ + class GenEvent; +} + +namespace Sacrifice{ + + using TCLAP::SwitchArg; + using TCLAP::ValueArg; + + class PhotosHandler{ + + public: + + /** + * Constructor. Pass a TCLAP CmdLine + * + */ + PhotosHandler(TCLAP::CmdLine &cmd): + m_initialised(false), + m_photosSwitch("p", "photos", "Run Photos for QED radiation (default = off)", false), + m_irCutArg("q", "qed-ir-cutoff", "Overrides infra-red cutoff for Photos++ QED radiation", false, -1., "double"), + m_alphaQEDArg("a", "alpha-qed", "Alpha_QED for PHOTOS++ (default 0.00729735039)", false, 0.00729735039, "double"), + m_exponentiationSwitch("x", "no-exponentiation", "Turn OFF exponentiation mode for PHOTOS++ (default = on)", true){ + + cmd.add(m_photosSwitch); + cmd.add(m_irCutArg); + cmd.add(m_alphaQEDArg); + cmd.add(m_exponentiationSwitch); + } + + /// Is support for Photos compiled and available + bool isAvailable()const; + + /// Is Photos switched on in this run + bool isEnabled(){ + return m_photosSwitch.getValue(); + } + + /// Initialise the photos setup + void initialise(); + + /// Process a HepMC event + void process(HepMC::GenEvent *event)const; + + private: + + PhotosHandler(); + + bool m_initialised; + + SwitchArg m_photosSwitch; + ValueArg<double> m_irCutArg; + ValueArg<double> m_alphaQEDArg; + SwitchArg m_exponentiationSwitch; + + }; +} +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/UserHooksFactory.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/UserHooksFactory.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/UserHooksFactory.hh (revision 921) @@ -0,0 +1,81 @@ +#ifndef SACRIFICE_USERHOOKS_FACTORY_HH +#define SACRIFICE_USERHOOKS_FACTORY_HH + +#ifdef PYTHIA8176 +#include "UserHooks.h" +#else +#include "Pythia8/UserHooks.h" +#endif + +#include <string> +#include <map> + +namespace Sacrifice{ + + using Pythia8::UserHooks; + using std::string; + using std::map; + + + class UserHooksFactory{ + + public: + + static UserHooks* create(const string &hookName); + + /** + * Loads a library of UserHooks + */ + static void loadLibrary(const string &libName); + + /** + * \return the path to a user hooks library + */ + static string libraryPath(const string &libName); + + private: + + UserHooksFactory(){}; + + class ICreator{ + public: + virtual UserHooks *create() const = 0; + virtual ~ICreator(){}; + }; + + public: + + template <class T> + class Creator: public ICreator{ + + public: + + Creator(const string &name){ + m_name = name; + UserHooksFactory::s_creators()[name] = this; + } + + ~Creator(){ + if(s_creators()[m_name] == this){ + s_creators().erase(m_name); + } + } + + UserHooks *create()const{ + return new T; + } + + private: + + string m_name; + }; + + private: + + static map<string, const ICreator*> &s_creators(); + + }; +} + + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/Makefile.am (revision 921) @@ -0,0 +1,13 @@ +SUBDIRS = . + +nobase_pkginclude_HEADERS = UserHooksFactory.hh + +dist_noinst_HEADERS = BeamParticle.hh \ + Exceptions.hh \ + HepMCIOHandler.hh \ + MCUtilsHandler.hh \ + PhotosHandler.hh \ + Utils.hh + +dist_noinst_HEADERS += binreloc.h + Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/MCUtilsHandler.hh =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/MCUtilsHandler.hh (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice/MCUtilsHandler.hh (revision 921) @@ -0,0 +1,84 @@ +#ifndef SACRIFICE_MCUTILS_HANDLER_HH +#define SACRIFICE_MCUTILS_HANDLER_HH + +#include "tclap/CmdLine.h" + +#include <functional> + +#include <string> +#include <vector> +#include <map> + +namespace HepMC{ + class GenEvent; + class GenParticle; +} + +namespace Sacrifice{ + + using TCLAP::SwitchArg; + using TCLAP::ValueArg; + + using std::string; + using std::vector; + using std::map; + + typedef std::function<bool(const HepMC::GenParticle*)> Classifier; + + class MCUtilsHandler{ + + public: + + /** + * Constructor. Pass a TCLAP CmdLine and add the appropriate args if + * MCUtils support is available + */ + MCUtilsHandler(TCLAP::CmdLine &cmd); + + static bool isAvailable(); + + void filter(HepMC::GenEvent *event); + + class Selector{ + + public: + + bool operator()(const HepMC::GenParticle* p); + + void addParticle(int pid, const vector<int> &statuses){ + + m_pids[pid].insert(m_pids[pid].end(), statuses.begin(), statuses.end()); + return; + } + + private: + + /// map list of particle ids onto allowed statuses + map<int, vector<int> > m_pids; + + }; + + private: + + void initialise(); + + // is this instance to be initialised + bool m_doInitialise; + + // switch to turn on default "standard" slimming of HepMC record + // slims non-interesting, gen-specific and loop particles. + // Keeps full phase space though + SwitchArg m_slimArg; + + // filename specifying a list of particle definitions to keep + // if this exists then all other particles removed from the event + ValueArg<string> m_keepList; + + // list of classifiers to apply to the event + vector<Classifier> m_classifiers; + + Selector m_selector; + + }; +} +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/include/Sacrifice ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,4 ## +*~ +._* +Makefile.in +Makefile Index: tags/Sacrifice-1.1.1/Sacrifice/include/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/Makefile.am (revision 921) @@ -0,0 +1,4 @@ +SUBDIRS = Sacrifice tclap MCUtils HEPUtils + + + Index: tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils/Makefile.am (revision 921) @@ -0,0 +1,11 @@ +SUBDIRS = . + +dist_noinst_HEADERS = BinnedFn.h \ + Event.h \ + FastJet.h \ + Jet.h \ + MathUtils.h \ + Particle.h \ + PhaseSpace.h \ + Utils.h \ + Vectors.h Index: tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/include/HEPUtils ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,5 ## +*~ +._* +*.h +Makefile +Makefile.in Index: tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils/Makefile.am (revision 921) @@ -0,0 +1,15 @@ +SUBDIRS = . + +dist_noinst_HEADERS = Clustering.h \ + HepMCEventFilters.h \ + HepMCEventUtils.h \ + HepMCParticleClassifiers.h \ + HepMCParticleFilters.h \ + HepMCParticleUtils.h \ + HepMCUtils.h \ + HepMCVectors.h \ + HepMCVertexClassifiers.h \ + HepMCVertexUtils.h \ + MCUtils.h \ + PIDCodes.h \ + PIDUtils.h Index: tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/include/MCUtils ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,5 ## +*~ +._* +*.h +Makefile +Makefile.in Index: tags/Sacrifice-1.1.1/Sacrifice/include =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/include (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/include (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/include ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,4 ## +Makefile +Makefile.in +*~ +._* Index: tags/Sacrifice-1.1.1/Sacrifice/AUTHORS =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/AUTHORS (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/AUTHORS (revision 921) @@ -0,0 +1,3 @@ +James Monk <jmonk@cern.ch> + +Main routine taken from examples provided with Pythia 8 \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/INSTALL =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/INSTALL (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/INSTALL (revision 921) @@ -0,0 +1,370 @@ +Installation Instructions +************************* + +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, +Inc. + + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. + +Basic Installation +================== + + Briefly, the shell command `./configure && make && make install' +should configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + + The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package, generally using the just-built uninstalled binaries. + + 4. Type `make install' to install the programs and any data files and + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. + + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + +Installation Names +================== + + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + HP-UX `make' updates targets which have the same time stamps as +their prerequisites, which makes it generally unusable when shipped +generated files such as `configure' are involved. Use GNU `make' +instead. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `<wchar.h>' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS + KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: + + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. Index: tags/Sacrifice-1.1.1/Sacrifice/ChangeLog =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/ChangeLog (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/ChangeLog (revision 921) @@ -0,0 +1,90 @@ +2017-11-06 James Monk <jmonk@cern.ch> + * Removal of boost dependency, replaced by C++11 + * Clean up old uneccessary UserHooks + * Use zstr instead of boost for gzipping + * Update to newest MCUtils (1.3.1) + HEPUtils + * Default beam not set (Pythia sets pp) - allows beam to be set in cmd file, but still over-ridden on command line + * Default beam energy set to 13 TeV + * Tagging as 1.1.1 + +2016-11-17 James Monk <jmonk@cern.ch> + * Fix test for zlib support in pythia lib + +2016-04-01 James Monk <jmonk@cern.ch> + * set_crash_on_problem now set true + * tagging for release as 1.0.0 + +2014-11-26 James Monk <jmonk@cern.ch> + * Fix multiple weights and CCKW-L cross section + * Update A2-MSTW2008LO and AU2-CT10 for new Py8.2 PDF syntax + * Add lhapdfdummy to linker only for Pythia version less than 8.2 + * Option to slim the event record (-s) is now off by default. The option -s on the commandline now turns on the full event slimming (removes everything except final state particles) + +2016-11-15 James Monk <jmonk@cern.ch> + * Ignore events with 0 CKKW-L weight + +2014-09-18 James Monk <jmonk@cern.ch> + * Update build and params for Pythia 8.200 + +2014-02-26 James Monk <jmonk@cern.ch> + * change default beam energy to 8000 GeV + +2014-02-03 James Monk <jmonk@cern.ch> + * improve header directory structure to include/Sacrifice include/tclap etc. + * Download tarball of MCUtils headers and install in include if not already present there. + * Use the downloaded MCUtils unless otherwise specified + #increase version to 0.9.9, make tarball + +2013-11-25 James Monk <jmonk@cern.ch> + * Compatibility with Pythia 8.180 + +2013-07-29 James Monk <jmonk@cern.ch> + * PTRel_boostVetoedShower.cxx: another vetoed shower, this time implemented with a + boost that evolves during the evtn due to recoil. Should be identical to main31 + +2013-07-14 James Monk <jmonk@cern.ch> + * HepMC no longer optional. Doesn't really make sense, since HepMC output is the whole point + * Add option to produced gzip compressed output. + Option will only be present if Pythia itself was compiled with gzip support. + +2013-07-10 James Monk <jmonk@cern.ch> + * Optional support for MCUtils to provide reduced HepMC size through filtering + +2013-07-08 James Monk <jmonk@cern.ch> + * Suppress and Enhance MPI Userhooks. Veto events with MPI above and below a threshold + +2013-07-01 James Monk <jmonk@cern.ch> + * update m4 scripts for slc6 gcc 46 + * setupPythia.sh script adds LHAPATH + +2013-06-19 James Monk <jmonk@cern.ch> + * User hook for vetoed shower using relative pT and reduced scale, a la main31 + +2013-02-13 James Monk <jmonk@cern.ch> + * Update build system to support Pythia with gzip + +2013-01-28 James Monk <jmonk@cern.ch> + * Selection of UserHooks for vetoed shower with PoWHEG + WZVetoedShower.cxx vetoes emissions relative to the beam + QCDVetoedShower.cxx compares each emission to each PoWHEG leg + PoWHEGVetoedShower vetoes relative to the beam, but determines a new + definition of the veto scale + * The above author suggested veto schemes need testing and validating! + * Improved UserHook library loading (local directory, SACRIFICE_LIB_PATH, install lib dir) + +2013-01-24 James Monk <jmonk@cern.ch> + * Allow user configuration of the lcg tag for troublesome setups + +2012-12-13 James Monk <jmonk@cern.ch> + * Add support for loading user hooks on the cmd line + +2012-05-21 James Monk <jmonk@cern.ch> + * Initial check-in to AGILe svn repository + * Supports Pythia 8 with HepMC, LHAPDF, PHOTOS++ + * ./configure ^should^ discover all libraries from genser, if available + * Photos support optional (--enable-photos to turn it on) + * ~Replicates the ATLAS setup, including PHOTOS++ wrangling + * Setup script installed in share: source share/setupPythia8.sh + +2012-02-22 James Monk <jmonk@cern.ch> + * Initial version of Pythia 8 main program + build system Index: tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_enabled.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_enabled.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_enabled.cxx (revision 921) @@ -0,0 +1,79 @@ +#include "Sacrifice/PhotosHandler.hh" + +#include "Photos/Photos.h" +#include "Photos/PhotosHepMCEvent.h" +#include "Photos/Log.h" + +#include <iostream> +#include <stdexcept> + +#ifdef PHOTOS_HAS_NAMESPACE +using namespace Photospp; +#endif + +namespace Sacrifice{ + + bool PhotosHandler::isAvailable()const{ + return true; + } + + void PhotosHandler::process(HepMC::GenEvent *event)const{ + + if(!m_initialised) throw std::runtime_error("Tried to process Photos event without proper initialisation"); + + PhotosHepMCEvent photosEvent(event); + photosEvent.process(); + + return; + } + + void PhotosHandler::initialise(){ + + Photos::initialize(); + Photos::setAlphaQED(m_alphaQEDArg.getValue()); + Photos::setInterference(true); + Photos::setCorrectionWtForW(true); + Photos::maxWtInterference(3.); + Photos::forceMassFrom4Vector(true); + + // since we explictly request events in GeV + double MeV = 1.e-03; + + Photos::forceMassFromEventRecord(13); + Photos::forceMassFromEventRecord(15); + Photos::forceMass(11, 0.510998910 * MeV); + Photos::forceMassFromEventRecord(211); + Photos::setTopProcessRadiation(false); + +#ifdef PHOTOS_HAS_NAMESPACE + Photos::createHistoryEntries(true, 3); + Photospp::Log::LogWarning(false); +#else + Photos::createHistoryEntries(true); +#endif + + if(m_exponentiationSwitch.getValue()){ + std::cout<<"Using Photos exponentiation mode"<<std::endl; + Photos::setExponentiation(true); + }else{ + std::cout<<"Not using Photos exponentiation mode"<<std::endl; + Photos::setInfraredCutOff(0.01); + Photos::setDoubleBrem(true); + Photos::setQuatroBrem(false); + phokey_.iexp = 0; + } + + if(m_irCutArg.getValue() > 0.){ + std::cout<<"Setting PHOTOS IR cutoff to "<<m_irCutArg.getValue()<<std::endl; + Photos::setInfraredCutOff(m_irCutArg.getValue()); + } + + Photos::iniInfo(); + + m_initialised = true; + + return; + } + +} + Index: tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_disabled.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_disabled.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_disabled.cxx (revision 921) @@ -0,0 +1,32 @@ +#include "Sacrifice/MCUtilsHandler.hh" +#include <stdexcept> + +namespace Sacrifice{ + + bool MCUtilsHandler::Selector::operator()(const HepMC::GenParticle *p){ + + throw std::runtime_error("MCUtils support was not compiled. HepMC filtering is not available."); + return false; + } + + MCUtilsHandler::MCUtilsHandler(TCLAP::CmdLine &cmd): + m_slimArg("s", "slim-HepMC", "slim the HepMC record to remove gen-specific and non-interesting particles (default=true)", true), + m_keepList("k", "keep-particles", "give a txt file specifying list of pdgids and statuses to keep. All other particles removed", false, "", "string"){ + + } + + bool MCUtilsHandler::isAvailable(){return false;} + + void MCUtilsHandler::initialise(){ + + throw std::runtime_error("MCUtils support was not compiled. HepMC filtering is not available."); + return; + } + + void MCUtilsHandler::filter(HepMC::GenEvent *event){ + + throw std::runtime_error("MCUtils support was not compiled. HepMC filtering is not available."); + return; + } + +} Index: tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_no_gzip.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_no_gzip.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_no_gzip.cxx (revision 921) @@ -0,0 +1,25 @@ +#include "Sacrifice/HepMCIOHandler.hh" + +namespace Sacrifice{ + + HepMCIOHandler::HepMCIOHandler(TCLAP::CmdLine &cmd): + m_doInitialise(true), + m_zipArg("z", "gzip-HepMC", "Compress the output HepMC file using gzip", false), + m_outputArg("o", "output", "Output HepMC file", false, "pythia.hepmc", "string"){ + + cmd.add(m_outputArg); + } + + void HepMCIOHandler::initialise(){ + + string name = m_outputArg.getValue(); + m_ostr.reset(new std::ofstream(name.c_str(), std::ios::out)); + m_io.reset(new HepMC::IO_GenEvent(*m_ostr)); + + m_doInitialise = false; + + return; + } + +} + Index: tags/Sacrifice-1.1.1/Sacrifice/src/BeamParticle.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/BeamParticle.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/BeamParticle.cxx (revision 921) @@ -0,0 +1,22 @@ +#include "Sacrifice/BeamParticle.hh" +#include <iostream> + +namespace Sacrifice{ + + bool BeamParticle::s_init = true; + + std::map<std::string, BeamParticle::PDGID> &BeamParticle::s_particleIDs(){ + + static std::map<std::string, PDGID> particleIDs; + + if(s_init){ + + particleIDs["PROTON"] = PROTON; + particleIDs["ANTIPROTON"] = ANTIPROTON; + particleIDs["ELECTRON"] = ELECTRON; + particleIDs["POSITRON"] = POSITRON; + s_init = false; + } + return particleIDs; + } +} Index: tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_enabled.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_enabled.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/MCUtilsHandler_enabled.cxx (revision 921) @@ -0,0 +1,154 @@ +#include "Sacrifice/MCUtilsHandler.hh" + +#include "MCUtils/HepMCUtils.h" + +#include "HepMC/IO_GenEvent.h" + +#include <fstream> +#include <regex> +#include <stdexcept> + +namespace Sacrifice{ + + using std::regex; + using std::regex_search; + using std::regex_match; + + inline bool _isPID0(const HepMC::GenParticle* p) { + return p->pdg_id() == 0; + } + + // Identify non-transportable stuff _after_ hadronisation + inline bool _isNonTransportableInDecayChain(const HepMC::GenParticle* p) { + return !MCUtils::isTransportable(p) && MCUtils::fromDecay(p); + } + + // Identify unstable hadrons from decay chains not containing heavy flavour or taus + // Partons with status 2 are also kept, but only because PYTHIA6 *wrongly* sets shower partons to have status == 2 + inline bool _inBoringDecayChain(const HepMC::GenParticle* p) { + return MCUtils::isDecayed(p) && !(MCUtils::isParton(p) || MCUtils::fromTauOrHFDecay(p)); + } + + /// Identify internal "loop" particles + inline bool _isLoop(const HepMC::GenParticle* p) { + return p->production_vertex() == p->end_vertex() && p->end_vertex() != NULL; + } + + ////////////////////////////////////////////////////////////////////////////// + + bool MCUtilsHandler::Selector::operator()(const HepMC::GenParticle *p){ + + if(p->is_beam()) return false; + + map<int, vector<int> >::const_iterator statuses = m_pids.find(abs(p->pdg_id())); + if(statuses != m_pids.end()){ + + if(statuses->second.size() == 0) return false; + + for(int status: statuses->second){ + if(status == p->status()) return false; + } + } + + statuses = m_pids.find(0); + if(statuses == m_pids.end() || statuses->second.size() == 0) return true; + + for(int status: statuses->second){ + if(status == p->status()) return false; + } + + return true; + } + + ////////////////////////////////////////////////////////////////////////////// + + MCUtilsHandler::MCUtilsHandler(TCLAP::CmdLine &cmd): + m_doInitialise(true), + m_slimArg("s", "slim-HepMC", "slim the HepMC record to remove gen-specific and non-interesting particles (default=false)", false), + m_keepList("k", "keep-particles", "give a txt file specifying list of pdgids and statuses to keep. All other particles removed", false, "", "string"){ + + cmd.add(m_slimArg); + cmd.add(m_keepList); + } + + bool MCUtilsHandler::isAvailable(){return true;} + + void MCUtilsHandler::initialise(){ + + if(m_slimArg.getValue()){ + std::cout<<std::endl<<" === Applying default HepMC filtering ==="<<std::endl<<std::endl; + m_classifiers.push_back(MCUtils::isGenSpecific); + m_classifiers.push_back(MCUtils::hasNonStandardStatus); + m_classifiers.push_back(_isPID0); + m_classifiers.push_back(_isNonTransportableInDecayChain); + m_classifiers.push_back(_inBoringDecayChain); + m_classifiers.push_back(_isLoop); + } + + regex removeComment("[^\\[c!#\\]]*"); + regex matchCommand(" *[+-]?\\d* *: *([+-]?\\d+ *)+"); + regex findPID(" *[+-]?(\\d+)? *:"); + regex findInt("[+-]?\\d+[^ :]"); + + if(m_keepList.getValue() != ""){ + std::ifstream file(m_keepList.getValue().c_str()); + + if(file.is_open()){ + while(file.good()){ + string line; + getline(file, line); + + std::smatch result; + + // Search for string up to comment command [c!#] + regex_search(line, result, removeComment); + + string command = result.str(); + + if(command == "") continue; + + // Check command matches form ID:status + if(!regex_match(command, matchCommand)){ + throw std::runtime_error("Particle filtering command is not understood: " + command); + } + + regex_search(command, result, findPID); + command = result.suffix().str(); + regex_search(result.str(), result, findInt); + int pid = (result.str() == "")? 0: std::stoi(result.str()); + + vector<int> statuses; + + while(regex_search(command, result, findInt)){ + statuses.push_back(std::stoi(result.str())); + command = result.suffix().str(); + } + + m_selector.addParticle(abs(pid), statuses); + + } + }else{ + throw std::runtime_error("Unable to open file: " + m_keepList.getValue()); + } + + m_classifiers.push_back(m_selector); + } + + m_doInitialise = false; + return; + } + + void MCUtilsHandler::filter(HepMC::GenEvent *event){ + + if(m_doInitialise) initialise(); + + const std::vector<HepMC::GenParticle*> toRemove + = MCUtils::particles_match_any(event, m_classifiers); + + MCUtils::reduce(event, toRemove); + + return; + } + +} + Index: tags/Sacrifice-1.1.1/Sacrifice/src/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/Makefile.am (revision 921) @@ -0,0 +1,48 @@ +SUBDIRS = . + +bin_PROGRAMS = run-pythia + +run_pythia_SOURCES = BeamParticle.cxx UserHooksFactory.cxx PythiaMain.cxx + +run_pythia_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHIA_CPPFLAGS) +run_pythia_CPPFLAGS += -DENABLE__BINRELOC +run_pythia_CPPFLAGS += -DDEFAULTDATADIR=\"$(PYTHIA_DATA)\" +run_pythia_CPPFLAGS += -DDEFAULTPARAMDIR=\"$(datadir)/Sacrifice\" +run_pythia_CPPFLAGS += -DDEFAULTLIBDIR=\"$(libdir)\" +run_pythia_LDFLAGS = $(AM_LDFLAGS) $(PYTHIA_LDFLAGS) -ldl -rdynamic +run_pythia_LDADD = $(AM_LDADD) + +if ENABLE_HEPMC +run_pythia_CPPFLAGS += $(HEPMC_CPPFLAGS) -DHAS_HEPMC +run_pythia_LDFLAGS += $(HEPMC_LDFLAGS) +endif + +if ENABLE_MCUTILS +run_pythia_CPPFLAGS += $(MCUTILS_CPPFLAGS) -DHAS_MCUTILS +run_pythia_SOURCES += MCUtilsHandler_enabled.cxx +else +run_pythia_SOURCES += MCUtilsHandler_disabled.cxx +endif + +if ENABLE_LHAPDF +run_pythia_CPPFLAGS += $(LHAPDF_CPPFLAGS) +run_pythia_LDFLAGS += $(LHAPDF_LDFLAGS) +endif + +if ENABLE_PHOTOS +run_pythia_SOURCES += PhotosHandler_enabled.cxx +run_pythia_CPPFLAGS += $(PHOTOS_CPPFLAGS) -DHAS_PHOTOS +run_pythia_LDFLAGS += $(PHOTOS_LDFLAGS) +else +run_pythia_SOURCES += PhotosHandler_disabled.cxx +endif + +if ENABLE_GZIP +run_pythia_SOURCES += HepMCIOHandler_gzip.cxx +else +run_pythia_SOURCES += HepMCIOHandler_no_gzip.cxx +endif + +run_pythia_SOURCES += binreloc.c + +EXTRA_DIST = zstr Index: tags/Sacrifice-1.1.1/Sacrifice/src/UserHooksFactory.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/UserHooksFactory.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/UserHooksFactory.cxx (revision 921) @@ -0,0 +1,93 @@ +#include "Sacrifice/UserHooksFactory.hh" +#include "Sacrifice/binreloc.h" + +#include <dlfcn.h> +#include <stdexcept> +#include <vector> + +namespace Sacrifice{ + + using std::vector; + using std::ifstream; + + ////////////////////////////////////////////////////////////////////////////// + UserHooks *UserHooksFactory::create(const string &name){ + map<string, const ICreator*>::const_iterator it = s_creators().find(name); + if(it == s_creators().end()){ + //eek! + throw std::runtime_error("UserHooksFactory: cannot create user hook " + name); + } + return it->second->create(); + } + + ////////////////////////////////////////////////////////////////////////////// + string UserHooksFactory::libraryPath(const string &libName){ + vector<string> libNames; + libNames.push_back(libName); + libNames.push_back(libName + ".so"); + libNames.push_back("Sacrifice" + libName); + libNames.push_back("Sacrifice" + libName + ".so"); + + vector<string> toCheck; + + char *envPath=0; + envPath = getenv("SACRIFICE_LIB_PATH"); + if(envPath){ + string sPath = string(envPath); + for(vector<string>::const_iterator name = libNames.begin(); + name != libNames.end(); ++name){ + toCheck.push_back(sPath + "/" + *name); + } + } + + for(vector<string>::const_iterator name = libNames.begin(); + name != libNames.end(); ++name){ + toCheck.push_back("./" + *name); + } + + BrInitError brError; + br_init_lib(&brError); + string defaultPath = br_find_data_dir(DEFAULTLIBDIR); + + for(vector<string>::const_iterator name = libNames.begin(); + name != libNames.end(); ++name){ + toCheck.push_back(defaultPath + "/" + *name); + } + + vector<string>::const_iterator file = toCheck.begin(); + + while(file != toCheck.end()){ + + ifstream testFile(file->c_str(), ifstream::in); + if(testFile.is_open()) break; + ++file; + } + + string path = (file == toCheck.end())? libName: *file; + return path; + } + + ////////////////////////////////////////////////////////////////////////////// + void UserHooksFactory::loadLibrary(const string &libName){ + + string path = libraryPath(libName); + + std::cout<<"Opening UserHook library at "<<path<<std::endl; + + void *libptr = dlopen(path.c_str(), RTLD_LAZY); + + if(libptr == 0){ + std::cout<<dlerror()<<std::endl; + throw std::runtime_error("UserHooksFactory: Unable to open library: " + path); + } + + return; + } + + ///static function to instantiate map of string name Vs. creator object on first use + map<string, const UserHooksFactory::ICreator*> &UserHooksFactory::s_creators(){ + static map<string, const UserHooksFactory::ICreator*> creators; + return creators; + } + +} Index: tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_gzip.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_gzip.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/HepMCIOHandler_gzip.cxx (revision 921) @@ -0,0 +1,39 @@ +#include "Sacrifice/HepMCIOHandler.hh" + +#include "zstr/zstr.hpp" + +namespace Sacrifice{ + + HepMCIOHandler::HepMCIOHandler(TCLAP::CmdLine &cmd): + m_doInitialise(true), + m_zipArg("z", "gzip-HepMC", "Compress the output HepMC file using gzip", false), + m_outputArg("o", "output", "Output HepMC file", false, "pythia.hepmc", "string"){ + + cmd.add(m_zipArg); + cmd.add(m_outputArg); + } + + void HepMCIOHandler::initialise(){ + + if(m_zipArg.getValue()){ + + string name = m_outputArg.getValue() + ".gz"; + + m_ostr.reset(new zstr::ofstream(name)); + + m_io.reset(new HepMC::IO_GenEvent(*m_ostr)); + + }else{ + string name = m_outputArg.getValue(); + m_ostr.reset(new std::ofstream(name.c_str(), std::ios::out)); + m_io.reset(new HepMC::IO_GenEvent(*m_ostr)); + } + + m_doInitialise = false; + + return; + } + +} + + Index: tags/Sacrifice-1.1.1/Sacrifice/src/binreloc.c =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/binreloc.c (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/binreloc.c (revision 921) @@ -0,0 +1,791 @@ +/* + * BinReloc - a library for creating relocatable executables + * Written by: Hongli Lai <h.lai@chello.nl> + * http://autopackage.org/ + * + * This source code is public domain. You can relicense this code + * under whatever license you want. + * + * See http://autopackage.org/docs/binreloc/ for + * more information and how to use this. + */ + +#ifndef __BINRELOC_C__ +#define __BINRELOC_C__ + +#ifdef ENABLE_BINRELOC + #include <sys/types.h> + #include <sys/stat.h> + #include <unistd.h> +#endif /* ENABLE_BINRELOC */ +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <string.h> +#include "Sacrifice/binreloc.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** @internal + * Find the canonical filename of the executable. Returns the filename + * (which must be freed) or NULL on error. If the parameter 'error' is + * not NULL, the error code will be stored there, if an error occured. + */ +static char * +_br_find_exe (BrInitError *error) +{ +#ifndef ENABLE_BINRELOC + if (error) + *error = BR_INIT_ERROR_DISABLED; + return NULL; +#else + char *path, *path2, *line, *result; + size_t buf_size; + ssize_t size; + struct stat stat_buf; + FILE *f; + + /* Read from /proc/self/exe (symlink) */ + if (sizeof (path) > SSIZE_MAX) + buf_size = SSIZE_MAX - 1; + else + buf_size = PATH_MAX - 1; + path = (char *) malloc (buf_size); + if (path == NULL) { + /* Cannot allocate memory. */ + if (error) + *error = BR_INIT_ERROR_NOMEM; + return NULL; + } + path2 = (char *) malloc (buf_size); + if (path2 == NULL) { + /* Cannot allocate memory. */ + if (error) + *error = BR_INIT_ERROR_NOMEM; + free (path); + return NULL; + } + + strncpy (path2, "/proc/self/exe", buf_size - 1); + + while (1) { + int i; + + size = readlink (path2, path, buf_size - 1); + if (size == -1) { + /* Error. */ + free (path2); + break; + } + + /* readlink() success. */ + path[size] = '\0'; + + /* Check whether the symlink's target is also a symlink. + * We want to get the final target. */ + i = stat (path, &stat_buf); + if (i == -1) { + /* Error. */ + free (path2); + break; + } + + /* stat() success. */ + if (!S_ISLNK (stat_buf.st_mode)) { + /* path is not a symlink. Done. */ + free (path2); + return path; + } + + /* path is a symlink. Continue loop and resolve this. */ + strncpy (path, path2, buf_size - 1); + } + + + /* readlink() or stat() failed; this can happen when the program is + * running in Valgrind 2.2. Read from /proc/self/maps as fallback. */ + + buf_size = PATH_MAX + 128; + line = (char *) realloc (path, buf_size); + if (line == NULL) { + /* Cannot allocate memory. */ + free (path); + if (error) + *error = BR_INIT_ERROR_NOMEM; + return NULL; + } + + f = fopen ("/proc/self/maps", "r"); + if (f == NULL) { + free (line); + if (error) + *error = BR_INIT_ERROR_OPEN_MAPS; + return NULL; + } + + /* The first entry should be the executable name. */ + result = fgets (line, (int) buf_size, f); + if (result == NULL) { + fclose (f); + free (line); + if (error) + *error = BR_INIT_ERROR_READ_MAPS; + return NULL; + } + + /* Get rid of newline character. */ + buf_size = strlen (line); + if (buf_size <= 0) { + /* Huh? An empty string? */ + fclose (f); + free (line); + if (error) + *error = BR_INIT_ERROR_INVALID_MAPS; + return NULL; + } + if (line[buf_size - 1] == 10) + line[buf_size - 1] = 0; + + /* Extract the filename; it is always an absolute path. */ + path = strchr (line, '/'); + + /* Sanity check. */ + if (strstr (line, " r-xp ") == NULL || path == NULL) { + fclose (f); + free (line); + if (error) + *error = BR_INIT_ERROR_INVALID_MAPS; + return NULL; + } + + path = strdup (path); + free (line); + fclose (f); + return path; +#endif /* ENABLE_BINRELOC */ +} + + +/** @internal + * Find the canonical filename of the executable which owns symbol. + * Returns a filename which must be freed, or NULL on error. + */ +static char * +_br_find_exe_for_symbol (const void *symbol, BrInitError *error) +{ +#ifndef ENABLE_BINRELOC + if (error) + *error = BR_INIT_ERROR_DISABLED; + return (char *) NULL; +#else + #define SIZE PATH_MAX + 100 + FILE *f; + size_t address_string_len; + char *address_string, line[SIZE], *found; + + if (symbol == NULL) + return (char *) NULL; + + f = fopen ("/proc/self/maps", "r"); + if (f == NULL) + return (char *) NULL; + + address_string_len = 4; + address_string = (char *) malloc (address_string_len); + /* Handle OOM (Tracker issue #35) */ + if (!address_string) + { + if (error) + *error = BR_INIT_ERROR_NOMEM; + return (char *) NULL; + } + found = (char *) NULL; + + while (!feof (f)) { + char *start_addr, *end_addr, *end_addr_end, *file; + void *start_addr_p, *end_addr_p; + size_t len; + + if (fgets (line, SIZE, f) == NULL) + break; + + /* Sanity check. */ + if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL) + continue; + + /* Parse line. */ + start_addr = line; + end_addr = strchr (line, '-'); + file = strchr (line, '/'); + + /* More sanity check. */ + if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-')) + continue; + + end_addr[0] = '\0'; + end_addr++; + end_addr_end = strchr (end_addr, ' '); + if (end_addr_end == NULL) + continue; + + end_addr_end[0] = '\0'; + len = strlen (file); + if (len == 0) + continue; + if (file[len - 1] == '\n') + file[len - 1] = '\0'; + + /* Get rid of "(deleted)" from the filename. */ + len = strlen (file); + if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0) + file[len - 10] = '\0'; + + /* I don't know whether this can happen but better safe than sorry. */ + len = strlen (start_addr); + if (len != strlen (end_addr)) + continue; + + + /* Transform the addresses into a string in the form of 0xdeadbeef, + * then transform that into a pointer. */ + if (address_string_len < len + 3) { + address_string_len = len + 3; + address_string = (char *) realloc (address_string, address_string_len); + /* Handle OOM (Tracker issue #35) */ + if (!address_string) + { + if (error) + *error = BR_INIT_ERROR_NOMEM; + return (char *) NULL; + } + } + + memcpy (address_string, "0x", 2); + memcpy (address_string + 2, start_addr, len); + address_string[2 + len] = '\0'; + sscanf (address_string, "%p", &start_addr_p); + + memcpy (address_string, "0x", 2); + memcpy (address_string + 2, end_addr, len); + address_string[2 + len] = '\0'; + sscanf (address_string, "%p", &end_addr_p); + + + if (symbol >= start_addr_p && symbol < end_addr_p) { + found = file; + break; + } + } + + free (address_string); + fclose (f); + + if (found == NULL) + return (char *) NULL; + else + return strdup (found); +#endif /* ENABLE_BINRELOC */ +} + + +#ifndef BINRELOC_RUNNING_DOXYGEN + #undef NULL + #define NULL ((char *) 0) /* typecasted as char* for C++ type safeness */ +#endif + +static char *exe = (char *) NULL; + + +/** Initialize the BinReloc library (for applications). + * + * This function must be called before using any other BinReloc functions. + * It attempts to locate the application's canonical filename. + * + * @note If you want to use BinReloc for a library, then you should call + * br_init_lib() instead. + * @note Initialization failure is not fatal. BinReloc functions will just + * fallback to the supplied default path. + * + * @param error If BinReloc failed to initialize, then the error code will + * be stored in this variable. Set to NULL if you want to + * ignore this. See #BrInitError for a list of error codes. + * + * @returns 1 on success, 0 if BinReloc failed to initialize. + */ +int +br_init (BrInitError *error) +{ + exe = _br_find_exe (error); + return exe != NULL; +} + + +/** Initialize the BinReloc library (for libraries). + * + * This function must be called before using any other BinReloc functions. + * It attempts to locate the calling library's canonical filename. + * + * @note The BinReloc source code MUST be included in your library, or this + * function won't work correctly. + * @note Initialization failure is not fatal. BinReloc functions will just + * fallback to the supplied default path. + * + * @param error If BinReloc failed to initialize, then the error code will + * be stored in this variable. Set to NULL if you want to + * ignore this. See #BrInitError for a list of error codes. + * + * @returns 1 on success, 0 if a filename cannot be found. + */ +int +br_init_lib (BrInitError *error) +{ + exe = _br_find_exe_for_symbol ((const void *) "", error); + return exe != NULL; +} + + +/** Find the canonical filename of the current application. + * + * @param default_exe A default filename which will be used as fallback. + * @returns A string containing the application's canonical filename, + * which must be freed when no longer necessary. If BinReloc is + * not initialized, or if br_init() failed, then a copy of + * default_exe will be returned. If default_exe is NULL, then + * NULL will be returned. + */ +char * +br_find_exe (const char *default_exe) +{ + if (exe == (char *) NULL) { + /* BinReloc is not initialized. */ + if (default_exe != (const char *) NULL) + return strdup (default_exe); + else + return (char *) NULL; + } + return strdup (exe); +} + + +/** Locate the directory in which the current application is installed. + * + * The prefix is generated by the following pseudo-code evaluation: + * \code + * dirname(exename) + * \endcode + * + * @param default_dir A default directory which will used as fallback. + * @return A string containing the directory, which must be freed when no + * longer necessary. If BinReloc is not initialized, or if the + * initialization function failed, then a copy of default_dir + * will be returned. If default_dir is NULL, then NULL will be + * returned. + */ +char * +br_find_exe_dir (const char *default_dir) +{ + if (exe == NULL) { + /* BinReloc not initialized. */ + if (default_dir != NULL) + return strdup (default_dir); + else + return NULL; + } + + return br_dirname (exe); +} + + +/** Locate the prefix in which the current application is installed. + * + * The prefix is generated by the following pseudo-code evaluation: + * \code + * dirname(dirname(exename)) + * \endcode + * + * @param default_prefix A default prefix which will used as fallback. + * @return A string containing the prefix, which must be freed when no + * longer necessary. If BinReloc is not initialized, or if + * the initialization function failed, then a copy of default_prefix + * will be returned. If default_prefix is NULL, then NULL will be returned. + */ +char * +br_find_prefix (const char *default_prefix) +{ + char *dir1, *dir2; + + if (exe == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_prefix != (const char *) NULL) + return strdup (default_prefix); + else + return (char *) NULL; + } + + dir1 = br_dirname (exe); + dir2 = br_dirname (dir1); + free (dir1); + return dir2; +} + + +/** Locate the application's binary folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/bin" + * \endcode + * + * @param default_bin_dir A default path which will used as fallback. + * @return A string containing the bin folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if + * the initialization function failed, then a copy of default_bin_dir will + * be returned. If default_bin_dir is NULL, then NULL will be returned. + */ +char * +br_find_bin_dir (const char *default_bin_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_bin_dir != (const char *) NULL) + return strdup (default_bin_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "bin"); + free (prefix); + return dir; +} + + +/** Locate the application's superuser binary folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/sbin" + * \endcode + * + * @param default_sbin_dir A default path which will used as fallback. + * @return A string containing the sbin folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the + * initialization function failed, then a copy of default_sbin_dir will + * be returned. If default_bin_dir is NULL, then NULL will be returned. + */ +char * +br_find_sbin_dir (const char *default_sbin_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_sbin_dir != (const char *) NULL) + return strdup (default_sbin_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "sbin"); + free (prefix); + return dir; +} + + +/** Locate the application's data folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/share" + * \endcode + * + * @param default_data_dir A default path which will used as fallback. + * @return A string containing the data folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the + * initialization function failed, then a copy of default_data_dir + * will be returned. If default_data_dir is NULL, then NULL will be + * returned. + */ +char * +br_find_data_dir (const char *default_data_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_data_dir != (const char *) NULL) + return strdup (default_data_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "share"); + free (prefix); + return dir; +} + + +/** Locate the application's localization folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/share/locale" + * \endcode + * + * @param default_locale_dir A default path which will used as fallback. + * @return A string containing the localization folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the + * initialization function failed, then a copy of default_locale_dir will be returned. + * If default_locale_dir is NULL, then NULL will be returned. + */ +char * +br_find_locale_dir (const char *default_locale_dir) +{ + char *data_dir, *dir; + + data_dir = br_find_data_dir ((const char *) NULL); + if (data_dir == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_locale_dir != (const char *) NULL) + return strdup (default_locale_dir); + else + return (char *) NULL; + } + + dir = br_build_path (data_dir, "locale"); + free (data_dir); + return dir; +} + + +/** Locate the application's library folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/lib" + * \endcode + * + * @param default_lib_dir A default path which will used as fallback. + * @return A string containing the library folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the initialization + * function failed, then a copy of default_lib_dir will be returned. + * If default_lib_dir is NULL, then NULL will be returned. + */ +char * +br_find_lib_dir (const char *default_lib_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_lib_dir != (const char *) NULL) + return strdup (default_lib_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "lib"); + free (prefix); + return dir; +} + + +/** Locate the application's libexec folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/libexec" + * \endcode + * + * @param default_libexec_dir A default path which will used as fallback. + * @return A string containing the libexec folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the initialization + * function failed, then a copy of default_libexec_dir will be returned. + * If default_libexec_dir is NULL, then NULL will be returned. + */ +char * +br_find_libexec_dir (const char *default_libexec_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_libexec_dir != (const char *) NULL) + return strdup (default_libexec_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "libexec"); + free (prefix); + return dir; +} + + +/** Locate the application's configuration files folder. + * + * The path is generated by the following pseudo-code evaluation: + * \code + * prefix + "/etc" + * \endcode + * + * @param default_etc_dir A default path which will used as fallback. + * @return A string containing the etc folder's path, which must be freed when + * no longer necessary. If BinReloc is not initialized, or if the initialization + * function failed, then a copy of default_etc_dir will be returned. + * If default_etc_dir is NULL, then NULL will be returned. + */ +char * +br_find_etc_dir (const char *default_etc_dir) +{ + char *prefix, *dir; + + prefix = br_find_prefix ((const char *) NULL); + if (prefix == (char *) NULL) { + /* BinReloc not initialized. */ + if (default_etc_dir != (const char *) NULL) + return strdup (default_etc_dir); + else + return (char *) NULL; + } + + dir = br_build_path (prefix, "etc"); + free (prefix); + return dir; +} + + +/*********************** + * Utility functions + ***********************/ + +/** Concatenate str1 and str2 to a newly allocated string. + * + * @param str1 A string. + * @param str2 Another string. + * @returns A newly-allocated string. This string should be freed when no longer needed. + */ +char * +br_strcat (const char *str1, const char *str2) +{ + char *result; + size_t len1, len2; + + if (str1 == NULL) + str1 = ""; + if (str2 == NULL) + str2 = ""; + + len1 = strlen (str1); + len2 = strlen (str2); + + result = (char *) malloc (len1 + len2 + 1); + /* Handle OOM (Tracker issue #35) */ + if (result) + { + memcpy (result, str1, len1); + memcpy (result + len1, str2, len2); + result[len1 + len2] = '\0'; + } + return result; +} + + +char * +br_build_path (const char *dir, const char *file) +{ + char *dir2, *result; + size_t len; + int must_free = 0; + + len = strlen (dir); + if (len > 0 && dir[len - 1] != '/') { + dir2 = br_strcat (dir, "/"); + must_free = 1; + } else + dir2 = (char *) dir; + + result = br_strcat (dir2, file); + if (must_free) + free (dir2); + return result; +} + + +/* Emulates glibc's strndup() */ +static char * +br_strndup (const char *str, size_t size) +{ + char *result = (char *) NULL; + size_t len; + + if (str == (const char *) NULL) + return (char *) NULL; + + len = strlen (str); + if (len == 0) + return strdup (""); + if (size > len) + size = len; + + result = (char *) malloc (len + 1); + /* Handle OOM (Tracker issue #35) */ + if (result) + { + memcpy (result, str, size); + result[size] = '\0'; + } + return result; +} + + +/** Extracts the directory component of a path. + * + * Similar to g_dirname() or the dirname commandline application. + * + * Example: + * \code + * br_dirname ("/usr/local/foobar"); --> Returns: "/usr/local" + * \endcode + * + * @param path A path. + * @returns A directory name. This string should be freed when no longer needed. + */ +char * +br_dirname (const char *path) +{ + char *end, *result; + + if (path == (const char *) NULL) + return (char *) NULL; + + end = strrchr (path, '/'); + if (end == (const char *) NULL) + return strdup ("."); + + while (end > path && *end == '/') + end--; + result = br_strndup (path, end - path + 1); + if (result[0] == 0) { + free (result); + return strdup ("/"); + } else + return result; +} + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __BINRELOC_C__ */ Index: tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_disabled.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_disabled.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/PhotosHandler_disabled.cxx (revision 921) @@ -0,0 +1,19 @@ +#include "Sacrifice/PhotosHandler.hh" +#include "Sacrifice/Exceptions.hh" + +namespace Sacrifice{ + + bool PhotosHandler::isAvailable()const{ + return false; + } + + void PhotosHandler::process(HepMC::GenEvent *event)const{ + throw PhotosException(); + } + + void PhotosHandler::initialise(){ + throw PhotosException(); + return; + } + +} Index: tags/Sacrifice-1.1.1/Sacrifice/src/zstr/strict_fstream.hpp =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/zstr/strict_fstream.hpp (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/zstr/strict_fstream.hpp (revision 921) @@ -0,0 +1,202 @@ +#ifndef __STRICT_FSTREAM_HPP +#define __STRICT_FSTREAM_HPP + +#include <cassert> +#include <fstream> +#include <cstring> +#include <string> + +/** + * This namespace defines wrappers for std::ifstream, std::ofstream, and + * std::fstream objects. The wrappers perform the following steps: + * - check the open modes make sense + * - check that the call to open() is successful + * - (for input streams) check that the opened file is peek-able + * - turn on the badbit in the exception mask + */ +namespace strict_fstream +{ + +/// Overload of error-reporting function, to enable use with VS. +/// Ref: http://stackoverflow.com/a/901316/717706 +static std::string strerror() +{ + std::string buff(80, '\0'); +#ifdef _WIN32 + if (strerror_s(&buff[0], buff.size(), errno) != 0) + { + buff = "Unknown error"; + } +#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || defined(__APPLE__) ) && ! _GNU_SOURCE +// XSI-compliant strerror_r() + if (strerror_r(errno, &buff[0], buff.size()) != 0) + { + buff = "Unknown error"; + } +#else +// GNU-specific strerror_r() + auto p = strerror_r(errno, &buff[0], buff.size()); + std::string tmp(p, std::strlen(p)); + std::swap(buff, tmp); +#endif + buff.resize(buff.find('\0')); + return buff; +} + +/// Exception class thrown by failed operations. +class Exception + : public std::exception +{ +public: + Exception(const std::string& msg) : _msg(msg) {} + const char * what() const noexcept { return _msg.c_str(); } +private: + std::string _msg; +}; // class Exception + +namespace detail +{ + +struct static_method_holder +{ + static std::string mode_to_string(std::ios_base::openmode mode) + { + static const int n_modes = 6; + static const std::ios_base::openmode mode_val_v[n_modes] = + { + std::ios_base::in, + std::ios_base::out, + std::ios_base::app, + std::ios_base::ate, + std::ios_base::trunc, + std::ios_base::binary + }; + + static const char * mode_name_v[n_modes] = + { + "in", + "out", + "app", + "ate", + "trunc", + "binary" + }; + std::string res; + for (int i = 0; i < n_modes; ++i) + { + if (mode & mode_val_v[i]) + { + res += (! res.empty()? "|" : ""); + res += mode_name_v[i]; + } + } + if (res.empty()) res = "none"; + return res; + } + static void check_mode(const std::string& filename, std::ios_base::openmode mode) + { + if ((mode & std::ios_base::trunc) && ! (mode & std::ios_base::out)) + { + throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and not out"); + } + else if ((mode & std::ios_base::app) && ! (mode & std::ios_base::out)) + { + throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: app and not out"); + } + else if ((mode & std::ios_base::trunc) && (mode & std::ios_base::app)) + { + throw Exception(std::string("strict_fstream: open('") + filename + "'): mode error: trunc and app"); + } + } + static void check_open(std::ios * s_p, const std::string& filename, std::ios_base::openmode mode) + { + if (s_p->fail()) + { + throw Exception(std::string("strict_fstream: open('") + + filename + "'," + mode_to_string(mode) + "): open failed: " + + strerror()); + } + } + static void check_peek(std::istream * is_p, const std::string& filename, std::ios_base::openmode mode) + { + bool peek_failed = true; + try + { + is_p->peek(); + peek_failed = is_p->fail(); + } + catch (std::ios_base::failure e) {} + if (peek_failed) + { + throw Exception(std::string("strict_fstream: open('") + + filename + "'," + mode_to_string(mode) + "): peek failed: " + + strerror()); + } + is_p->clear(); + } +}; // struct static_method_holder + +} // namespace detail + +class ifstream + : public std::ifstream +{ +public: + ifstream() = default; + ifstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + { + open(filename, mode); + } + void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + { + mode |= std::ios_base::in; + exceptions(std::ios_base::badbit); + detail::static_method_holder::check_mode(filename, mode); + std::ifstream::open(filename, mode); + detail::static_method_holder::check_open(this, filename, mode); + detail::static_method_holder::check_peek(this, filename, mode); + } +}; // class ifstream + +class ofstream + : public std::ofstream +{ +public: + ofstream() = default; + ofstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) + { + open(filename, mode); + } + void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) + { + mode |= std::ios_base::out; + exceptions(std::ios_base::badbit); + detail::static_method_holder::check_mode(filename, mode); + std::ofstream::open(filename, mode); + detail::static_method_holder::check_open(this, filename, mode); + } +}; // class ofstream + +class fstream + : public std::fstream +{ +public: + fstream() = default; + fstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + { + open(filename, mode); + } + void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + { + if (! (mode & std::ios_base::out)) mode |= std::ios_base::in; + exceptions(std::ios_base::badbit); + detail::static_method_holder::check_mode(filename, mode); + std::fstream::open(filename, mode); + detail::static_method_holder::check_open(this, filename, mode); + detail::static_method_holder::check_peek(this, filename, mode); + } +}; // class fstream + +} // namespace strict_fstream + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/src/zstr/LICENSE =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/zstr/LICENSE (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/zstr/LICENSE (revision 921) @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Matei David, Ontario Institute for Cancer Research + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. Index: tags/Sacrifice-1.1.1/Sacrifice/src/zstr/zstr.hpp =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/zstr/zstr.hpp (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/zstr/zstr.hpp (revision 921) @@ -0,0 +1,411 @@ +//--------------------------------------------------------- +// Copyright 2015 Ontario Institute for Cancer Research +// Written by Matei David (matei@cs.toronto.edu) +//--------------------------------------------------------- + +// Reference: +// http://stackoverflow.com/questions/14086417/how-to-write-custom-input-stream-in-c + +#ifndef __ZSTR_HPP +#define __ZSTR_HPP + +#include <cassert> +#include <fstream> +#include <sstream> +#include <zlib.h> +#include "strict_fstream.hpp" + +namespace zstr +{ + +/// Exception class thrown by failed zlib operations. +class Exception + : public std::exception +{ +public: + Exception(z_stream * zstrm_p, int ret) + : _msg("zlib: ") + { + switch (ret) + { + case Z_STREAM_ERROR: + _msg += "Z_STREAM_ERROR: "; + break; + case Z_DATA_ERROR: + _msg += "Z_DATA_ERROR: "; + break; + case Z_MEM_ERROR: + _msg += "Z_MEM_ERROR: "; + break; + case Z_VERSION_ERROR: + _msg += "Z_VERSION_ERROR: "; + break; + case Z_BUF_ERROR: + _msg += "Z_BUF_ERROR: "; + break; + default: + std::ostringstream oss; + oss << ret; + _msg += "[" + oss.str() + "]: "; + break; + } + _msg += zstrm_p->msg; + } + Exception(const std::string msg) : _msg(msg) {} + const char * what() const noexcept { return _msg.c_str(); } +private: + std::string _msg; +}; // class Exception + +namespace detail +{ + +class z_stream_wrapper + : public z_stream +{ +public: + z_stream_wrapper(bool _is_input = true, int _level = Z_DEFAULT_COMPRESSION) + : is_input(_is_input) + { + this->zalloc = Z_NULL; + this->zfree = Z_NULL; + this->opaque = Z_NULL; + int ret; + if (is_input) + { + this->avail_in = 0; + this->next_in = Z_NULL; + ret = inflateInit2(this, 15+32); + } + else + { + ret = deflateInit2(this, _level, Z_DEFLATED, 15+16, 8, Z_DEFAULT_STRATEGY); + } + if (ret != Z_OK) throw Exception(this, ret); + } + ~z_stream_wrapper() + { + if (is_input) + { + inflateEnd(this); + } + else + { + deflateEnd(this); + } + } +private: + bool is_input; +}; // class z_stream_wrapper + +} // namespace detail + +class istreambuf + : public std::streambuf +{ +public: + istreambuf(std::streambuf * _sbuf_p, + std::size_t _buff_size = default_buff_size, bool _auto_detect = true) + : sbuf_p(_sbuf_p), + zstrm_p(nullptr), + buff_size(_buff_size), + auto_detect(_auto_detect), + auto_detect_run(false), + is_text(false) + { + assert(sbuf_p); + in_buff = new char [buff_size]; + in_buff_start = in_buff; + in_buff_end = in_buff; + out_buff = new char [buff_size]; + setg(out_buff, out_buff, out_buff); + } + + istreambuf(const istreambuf &) = delete; + istreambuf(istreambuf &&) = default; + istreambuf & operator = (const istreambuf &) = delete; + istreambuf & operator = (istreambuf &&) = default; + + virtual ~istreambuf() + { + delete [] in_buff; + delete [] out_buff; + if (zstrm_p) delete zstrm_p; + } + + virtual std::streambuf::int_type underflow() + { + if (this->gptr() == this->egptr()) + { + // pointers for free region in output buffer + char * out_buff_free_start = out_buff; + do + { + // read more input if none available + if (in_buff_start == in_buff_end) + { + // empty input buffer: refill from the start + in_buff_start = in_buff; + std::streamsize sz = sbuf_p->sgetn(in_buff, buff_size); + in_buff_end = in_buff + sz; + if (in_buff_end == in_buff_start) break; // end of input + } + // auto detect if the stream contains text or deflate data + if (auto_detect && ! auto_detect_run) + { + auto_detect_run = true; + unsigned char b0 = *reinterpret_cast< unsigned char * >(in_buff_start); + unsigned char b1 = *reinterpret_cast< unsigned char * >(in_buff_start + 1); + // Ref: + // http://en.wikipedia.org/wiki/Gzip + // http://stackoverflow.com/questions/9050260/what-does-a-zlib-header-look-like + is_text = ! (in_buff_start + 2 <= in_buff_end + && ((b0 == 0x1F && b1 == 0x8B) // gzip header + || (b0 == 0x78 && (b1 == 0x01 // zlib header + || b1 == 0x9C + || b1 == 0xDA)))); + } + if (is_text) + { + // simply swap in_buff and out_buff, and adjust pointers + assert(in_buff_start == in_buff); + std::swap(in_buff, out_buff); + out_buff_free_start = in_buff_end; + in_buff_start = in_buff; + in_buff_end = in_buff; + } + else + { + // run inflate() on input + if (! zstrm_p) zstrm_p = new detail::z_stream_wrapper(true); + zstrm_p->next_in = reinterpret_cast< decltype(zstrm_p->next_in) >(in_buff_start); + zstrm_p->avail_in = in_buff_end - in_buff_start; + zstrm_p->next_out = reinterpret_cast< decltype(zstrm_p->next_out) >(out_buff_free_start); + zstrm_p->avail_out = (out_buff + buff_size) - out_buff_free_start; + int ret = inflate(zstrm_p, Z_NO_FLUSH); + // process return code + if (ret != Z_OK && ret != Z_STREAM_END) throw Exception(zstrm_p, ret); + // update in&out pointers following inflate() + in_buff_start = reinterpret_cast< decltype(in_buff_start) >(zstrm_p->next_in); + in_buff_end = in_buff_start + zstrm_p->avail_in; + out_buff_free_start = reinterpret_cast< decltype(out_buff_free_start) >(zstrm_p->next_out); + assert(out_buff_free_start + zstrm_p->avail_out == out_buff + buff_size); + // if stream ended, deallocate inflator + if (ret == Z_STREAM_END) + { + delete zstrm_p; + zstrm_p = nullptr; + } + } + } while (out_buff_free_start == out_buff); + // 2 exit conditions: + // - end of input: there might or might not be output available + // - out_buff_free_start != out_buff: output available + this->setg(out_buff, out_buff, out_buff_free_start); + } + return this->gptr() == this->egptr() + ? traits_type::eof() + : traits_type::to_int_type(*this->gptr()); + } +private: + std::streambuf * sbuf_p; + char * in_buff; + char * in_buff_start; + char * in_buff_end; + char * out_buff; + detail::z_stream_wrapper * zstrm_p; + std::size_t buff_size; + bool auto_detect; + bool auto_detect_run; + bool is_text; + + static const std::size_t default_buff_size = (std::size_t)1 << 20; +}; // class istreambuf + +class ostreambuf + : public std::streambuf +{ +public: + ostreambuf(std::streambuf * _sbuf_p, + std::size_t _buff_size = default_buff_size, int _level = Z_DEFAULT_COMPRESSION) + : sbuf_p(_sbuf_p), + zstrm_p(new detail::z_stream_wrapper(false, _level)), + buff_size(_buff_size) + { + assert(sbuf_p); + in_buff = new char [buff_size]; + out_buff = new char [buff_size]; + setp(in_buff, in_buff + buff_size); + } + + ostreambuf(const ostreambuf &) = delete; + ostreambuf(ostreambuf &&) = default; + ostreambuf & operator = (const ostreambuf &) = delete; + ostreambuf & operator = (ostreambuf &&) = default; + + int deflate_loop(int flush) + { + while (true) + { + zstrm_p->next_out = reinterpret_cast< decltype(zstrm_p->next_out) >(out_buff); + zstrm_p->avail_out = buff_size; + int ret = deflate(zstrm_p, flush); + if (ret != Z_OK && ret != Z_STREAM_END && ret != Z_BUF_ERROR) throw Exception(zstrm_p, ret); + std::streamsize sz = sbuf_p->sputn(out_buff, reinterpret_cast< decltype(out_buff) >(zstrm_p->next_out) - out_buff); + if (sz != reinterpret_cast< decltype(out_buff) >(zstrm_p->next_out) - out_buff) + { + // there was an error in the sink stream + return -1; + } + if (ret == Z_STREAM_END || ret == Z_BUF_ERROR || sz == 0) + { + break; + } + } + return 0; + } + + virtual ~ostreambuf() + { + // flush the zlib stream + // + // NOTE: Errors here (sync() return value not 0) are ignored, because we + // cannot throw in a destructor. This mirrors the behaviour of + // std::basic_filebuf::~basic_filebuf(). To see an exception on error, + // close the ofstream with an explicit call to close(), and do not rely + // on the implicit call in the destructor. + // + sync(); + delete [] in_buff; + delete [] out_buff; + delete zstrm_p; + } + virtual std::streambuf::int_type overflow(std::streambuf::int_type c = traits_type::eof()) + { + zstrm_p->next_in = reinterpret_cast< decltype(zstrm_p->next_in) >(pbase()); + zstrm_p->avail_in = pptr() - pbase(); + while (zstrm_p->avail_in > 0) + { + int r = deflate_loop(Z_NO_FLUSH); + if (r != 0) + { + setp(nullptr, nullptr); + return traits_type::eof(); + } + } + setp(in_buff, in_buff + buff_size); + return traits_type::eq_int_type(c, traits_type::eof()) ? traits_type::eof() : sputc(c); + } + virtual int sync() + { + // first, call overflow to clear in_buff + overflow(); + if (! pptr()) return -1; + // then, call deflate asking to finish the zlib stream + zstrm_p->next_in = nullptr; + zstrm_p->avail_in = 0; + if (deflate_loop(Z_FINISH) != 0) return -1; + deflateReset(zstrm_p); + return 0; + } +private: + std::streambuf * sbuf_p; + char * in_buff; + char * out_buff; + detail::z_stream_wrapper * zstrm_p; + std::size_t buff_size; + + static const std::size_t default_buff_size = (std::size_t)1 << 20; +}; // class ostreambuf + +class istream + : public std::istream +{ +public: + istream(std::istream & is) + : std::istream(new istreambuf(is.rdbuf())) + { + exceptions(std::ios_base::badbit); + } + explicit istream(std::streambuf * sbuf_p) + : std::istream(new istreambuf(sbuf_p)) + { + exceptions(std::ios_base::badbit); + } + virtual ~istream() + { + delete rdbuf(); + } +}; // class istream + +class ostream + : public std::ostream +{ +public: + ostream(std::ostream & os) + : std::ostream(new ostreambuf(os.rdbuf())) + { + exceptions(std::ios_base::badbit); + } + explicit ostream(std::streambuf * sbuf_p) + : std::ostream(new ostreambuf(sbuf_p)) + { + exceptions(std::ios_base::badbit); + } + virtual ~ostream() + { + delete rdbuf(); + } +}; // class ostream + +namespace detail +{ + +template < typename FStream_Type > +struct strict_fstream_holder +{ + strict_fstream_holder(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + : _fs(filename, mode) + {} + FStream_Type _fs; +}; // class strict_fstream_holder + +} // namespace detail + +class ifstream + : private detail::strict_fstream_holder< strict_fstream::ifstream >, + public std::istream +{ +public: + explicit ifstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::in) + : detail::strict_fstream_holder< strict_fstream::ifstream >(filename, mode), + std::istream(new istreambuf(_fs.rdbuf())) + { + exceptions(std::ios_base::badbit); + } + virtual ~ifstream() + { + if (rdbuf()) delete rdbuf(); + } +}; // class ifstream + +class ofstream + : private detail::strict_fstream_holder< strict_fstream::ofstream >, + public std::ostream +{ +public: + explicit ofstream(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) + : detail::strict_fstream_holder< strict_fstream::ofstream >(filename, mode | std::ios_base::binary), + std::ostream(new ostreambuf(_fs.rdbuf())) + { + exceptions(std::ios_base::badbit); + } + virtual ~ofstream() + { + if (rdbuf()) delete rdbuf(); + } +}; // class ofstream + +} // namespace zstr + +#endif Index: tags/Sacrifice-1.1.1/Sacrifice/src/zstr =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/zstr (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/src/zstr (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/src/zstr ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,6 ## +._* +*~ +.deps +*.o +Makefile +Makefile.in Index: tags/Sacrifice-1.1.1/Sacrifice/src/PythiaMain.cxx =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src/PythiaMain.cxx (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/src/PythiaMain.cxx (revision 921) @@ -0,0 +1,271 @@ +#ifdef PYTHIA8176 +#include "Pythia.h" +#include "HepMCInterface.h" +#define HepMCConverter HepMC::I_Pythia8 +#else +#include "Pythia8/Pythia.h" +#ifdef PYTHIA8200 +#include "Pythia8Plugins/HepMC2.h" +#else +#include "Pythia8/Pythia8ToHepMC.h" +#endif +#define HepMCConverter HepMC::Pythia8ToHepMC +#endif + +#include "Sacrifice/UserHooksFactory.hh" +#include "Sacrifice/Exceptions.hh" +#include "Sacrifice/BeamParticle.hh" +#include "Sacrifice/Utils.hh" + +#include "Sacrifice/HepMCIOHandler.hh" +#include "Sacrifice/MCUtilsHandler.hh" +#include "Sacrifice/PhotosHandler.hh" + +#include "Sacrifice/binreloc.h" +#include "tclap/CmdLine.h" + +#include "HepMC/GenEvent.h" +#include "HepMC/Units.h" + +#include <string> +#include <stdexcept> + +using namespace std; + +int main(int argc, char **argv){ + + char *envPath=0; + envPath = getenv("PYTHIA8DATA"); + + string path; + + if(envPath){ + path = envPath; + }else{ + BrInitError brError; + br_init_lib(&brError); + path = br_find_data_dir(DEFAULTDATADIR); + } + + //Do this first so we always get the Pythia banner and version information + Pythia8::Pythia pythia(path); + std::string pythiaVersion = to_string(pythia.settings.parm("Pythia:versionNumber") + 0.00000000001); + pythiaVersion.erase(5); + std::string message = "Main program for steering Pythia " + pythiaVersion + ". Bug reports to James Monk <jmonk@cern.ch>"; + + TCLAP::CmdLine cmd(message, ' ', "0.9.9"); + + Sacrifice::HepMCIOHandler hepMCHandler(cmd); + Sacrifice::PhotosHandler photosHandler(cmd); + Sacrifice::MCUtilsHandler mcutils(cmd); + + TCLAP::ValueArg<int> seedArg("r", "random-seed", "Random seed", false, -1, "int"); + TCLAP::MultiArg<std::string> inputArg("i", "input", "Input command file", false, "string"); + TCLAP::ValueArg<std::string> beam1Arg("f", "beam1", "Forward-going beam type", false, "", "string"); + TCLAP::ValueArg<std::string> beam2Arg("b", "beam2", "Backward-going beam type", false, "", "string"); + TCLAP::ValueArg<double> energyArg("e", "collision-energy", "Collision energy in GeV (default 13000 GeV)", false, 13000., "double"); + TCLAP::ValueArg<int> nEventsArg("n", "nEvents", "Number of events to generate (default 100)", false, 100, "int"); + TCLAP::MultiArg<std::string> paramsArgs("c", "command", "Commands to be read directly in to Pythia. Over-rides command file.", false, "string"); + TCLAP::ValueArg<std::string> dataArg("d", "particle-data", "XML file of particle data. Over-rides default in $PYTHIA8DATA.", false, "", "string"); + TCLAP::ValueArg<std::string> lhefArg("l", "lhe-file"," Les Houches Event File input", false, "", "string"); + TCLAP::ValueArg<std::string> libArg("L", "load-library", "Library of user hooks to be loaded", false, "Plugin", "string"); + TCLAP::ValueArg<std::string> hooksArg("u", "user-hook", "Name of user hook to add", false, "", "string"); + TCLAP::SwitchArg printArg("w", "write", "Write HepMC events to stdout", false); + TCLAP::ValueArg<int> maxFailureArg("m", "max-failures", "Maximum number of failed events", false, 10, "int"); + + + cmd.add(seedArg); + cmd.add(inputArg); + cmd.add(beam1Arg); + cmd.add(beam2Arg); + cmd.add(energyArg); + cmd.add(nEventsArg); + cmd.add(paramsArgs); + cmd.add(dataArg); + cmd.add(lhefArg); + cmd.add(libArg); + cmd.add(hooksArg); + cmd.add(printArg); + cmd.add(maxFailureArg); + + cmd.parse( argc, argv ); + + HepMCConverter pythiaToHepMC; + + pythiaToHepMC.set_store_pdf(true); +// pythiaToHepMC.set_crash_on_problem(true); + + if(photosHandler.isEnabled()){ + photosHandler.initialise(); + } + + for(vector<std::string>::const_iterator inputFile = inputArg.getValue().begin(); + inputFile != inputArg.getValue().end(); ++inputFile){ + + std::string path = Sacrifice::findParamFile(*inputFile); + if(!pythia.readFile(path)){ + throw std::runtime_error("Could not interpret all of the commands in the input file " + path + "!"); + }else{ + std::cout<<" Read commands from "<<path<<std::endl<<std::endl; + } + } + + for(vector<std::string>::const_iterator command = paramsArgs.getValue().begin(); + command != paramsArgs.getValue().end(); ++command){ + if(!pythia.readString(*command)){ + std::string msg = "Pythia could not understand the command " + *command; + throw std::runtime_error(msg); + } + } + + if(seedArg.getValue() > 0){ + std::string seedString = "Random:seed=" + to_string(seedArg.getValue()); + bool understood = pythia.readString("Random:setSeed=on"); + understood = understood && pythia.readString(seedString); + if(! understood) throw std::runtime_error("Your version of Pythia does not understand the random seed commands!"); + } + + if(photosHandler.isEnabled()){ + bool understood = pythia.readString("TimeShower:QEDshowerByL = off"); + if(! understood) throw std::runtime_error("Your version of Pythia does not understand the command to turn off QED FSR!"); + } + + if(hooksArg.getValue() != ""){ + Sacrifice::UserHooksFactory::loadLibrary(libArg.getValue()); + if(!pythia.setUserHooksPtr(Sacrifice::UserHooksFactory::create(hooksArg.getValue()))) + throw std::runtime_error("Unable to use UserHook: " + hooksArg.getValue()); + } + + /// @todo This doesn't work at the moment... the beam particles are not correctly handled and process init fails + if(dataArg.getValue() != ""){ + if(!pythia.particleData.reInit(dataArg.getValue(), true)) throw std::runtime_error("Could not read particle data file: " + dataArg.getValue()); + } + + bool isInitialised = true; + bool doLHEF = false; + + if(lhefArg.getValue() != ""){ + isInitialised = isInitialised && pythia.readString("Beams:frameType = 4"); + isInitialised = isInitialised && pythia.readString("Beams:LHEF = " + lhefArg.getValue()); + doLHEF = true; + }else{ + isInitialised = isInitialised && pythia.readString("Beams:frameType = 1"); + + if(beam1Arg.getValue() != ""){ + Sacrifice::BeamParticle beam1(beam1Arg.getValue()); + isInitialised = isInitialised && pythia.readString("Beams:idA = " + to_string(beam1.asID())); + } + + if(beam2Arg.getValue() != ""){ + Sacrifice::BeamParticle beam2(beam2Arg.getValue()); + isInitialised = isInitialised && pythia.readString("Beams:idB = " + to_string(beam2.asID())); + } + + isInitialised = isInitialised && pythia.readString("Beams:eCM = " + to_string(energyArg.getValue())); + } + + pythia.readString("Next:numberShowEvent = 0"); + + isInitialised = isInitialised && pythia.init(); + + if(!isInitialised) throw std::runtime_error("Could not initialise Pythia"); + + std::vector<std::string> weightIDs; + int failureCount=0; + double nMerged=0.; + double nAccepted=0.; + + for(int eventNumber = 0; eventNumber < nEventsArg.getValue(); ++eventNumber){ + + if(!pythia.next()){ + if(pythia.info.atEndOfFile()){ + std::cout<<"Reached end of LHE file"<<std::endl; + break; + } + + ++failureCount; + + if(failureCount > maxFailureArg.getValue()){ + std::cout<<"Number of failed events exceeds maximum of "<<maxFailureArg.getValue()<<std::endl; + break; + } + if(eventNumber == 0) --eventNumber; + } + + double phaseSpaceWeight = pythia.info.weight(); + double mergingWeight = pythia.info.mergingWeight(); + double eventWeight = phaseSpaceWeight*mergingWeight; + + nAccepted += 1.; + + if(fabs(eventWeight) < 1.e-18 || + pythia.event.size() < 2){ + + if(eventNumber == 0) --eventNumber; + continue; + }else{ + nMerged += eventWeight; + } + +#ifdef HEPMC_HAS_UNITS /// + HepMC::GenEvent *hepMCEvent = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM); +#else + HepMC::GenEvent *hepMCEvent = new HepMC::GenEvent(); +#endif /// HEPMC_HAS_UNITS + + pythiaToHepMC.fill_next_event(pythia, hepMCEvent); + + if(photosHandler.isEnabled()){ + photosHandler.process(hepMCEvent); + } + + if(mcutils.isAvailable()) mcutils.filter(hepMCEvent); + + hepMCEvent->weights().clear(); + + std::vector<std::string>::const_iterator id = weightIDs.begin(); + + if(pythia.info.getWeightsDetailedSize() != 0){ + + for(std::map<std::string, Pythia8::LHAwgt>::const_iterator wgt = pythia.info.rwgt->wgts.begin(); + wgt != pythia.info.rwgt->wgts.end(); ++wgt){ + + if(eventNumber == 0){ + weightIDs.push_back(wgt->first); + }else{ + if(*id != wgt->first){ + throw std::runtime_error("Mismatch in LHE3 weight name. Found" + wgt->first + ", expected " + *id); + } + ++id; + } + + std::map<std::string, Pythia8::LHAweight>::const_iterator weightName = pythia.info.init_weights->find(wgt->first); + if(weightName != pythia.info.init_weights->end()){ + hepMCEvent->weights()[weightName->second.contents] = mergingWeight * wgt->second.contents; + }else{ + hepMCEvent->weights()[wgt->first] = mergingWeight * wgt->second.contents; + } + + } + + }else{ + hepMCEvent->weights().push_back(eventWeight); + } + + if(printArg.getValue()){ + hepMCEvent->print(); + } + + + hepMCHandler.writeEvent(hepMCEvent); + + delete hepMCEvent; + + } + + pythia.stat(); + + double xs = pythia.info.sigmaGen(); // in mb + std::cout<<"Cross Section (nb) = "<<xs * 1000. *nMerged / nAccepted<<std::endl; + +} Index: tags/Sacrifice-1.1.1/Sacrifice/src =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/src (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice/src (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice/src ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,8 ## +._* +*~ +.deps +*.o +pythia +run-pythia +Makefile +Makefile.in Index: tags/Sacrifice-1.1.1/Sacrifice/COPYING =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/COPYING (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/COPYING (revision 921) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Index: tags/Sacrifice-1.1.1/Sacrifice/Makefile.am =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/Makefile.am (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/Makefile.am (revision 921) @@ -0,0 +1,2 @@ +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = src include UserHooks share \ No newline at end of file Index: tags/Sacrifice-1.1.1/Sacrifice/NEWS =================================================================== Index: tags/Sacrifice-1.1.1/Sacrifice/README =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice/README (revision 0) +++ tags/Sacrifice-1.1.1/Sacrifice/README (revision 921) @@ -0,0 +1,25 @@ +Main program for Pythia 8: You should make a sacrifice before you consult the Pythia. + +Optionally builds against HepMC, LHAPDF (default = yes) and PHOTOS++ (default = no). Requires the Pythia 8 library, of course. + +Help on building can be obtained by + + ./configure --help + +If on a machine with AFS access to Genser then the necessary libraries ^should^ be found with no further tweaking. + +Usually + + ./configure <--enable-photos> <--prefix=/path/to/install> <other options> + make + make install + +will do the trick. The executable is called run-pythia. A setup script, setupPythia.sh, will be installed in the share directory. + +Help is available with + + source setupPythia.sh + ./run-pythia --help + + + Index: tags/Sacrifice-1.1.1/Sacrifice =================================================================== --- tags/Sacrifice-1.1.1/Sacrifice (revision 920) +++ tags/Sacrifice-1.1.1/Sacrifice (revision 921) Property changes on: tags/Sacrifice-1.1.1/Sacrifice ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,11 ## +._* +*~ +Makefile +Makefile.in +configure +aclocal.m4 +config +autom4te.cache +config.log +config.status +libtool