diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40d565f..a76b261 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,252 +1,254 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
#Use the compilers found in the path
find_program(CMAKE_C_COMPILER NAMES $ENV{CC} gcc PATHS ENV PATH NO_DEFAULT_PATH)
find_program(CMAKE_CXX_COMPILER NAMES $ENV{CXX} g++ PATHS ENV PATH NO_DEFAULT_PATH)
project(NUISANCE)
include(ExternalProject)
enable_language(Fortran)
set (NUISANCE_VERSION_MAJOR 2)
set (NUISANCE_VERSION_MINOR 7)
set (NUISANCE_VERSION_REVISION 0)
set (NUISANCE_VERSION_STRING "v${NUISANCE_VERSION_MAJOR}r${NUISANCE_VERSION_MINOR}")
if(${NUISANCE_VERSION_REVISION} STRGREATER "0")
set (NUISANCE_VERSION_STRING "${NUISANCE_VERSION_STRING}p${NUISANCE_VERSION_REVISION}")
endif()
#Set this to TRUE to enable build debugging messages
set(BUILD_DEBUG_MSGS TRUE)
include(${CMAKE_SOURCE_DIR}/cmake/cmessage.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/cacheVariables.cmake)
cmessage(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"")
cmessage(STATUS "CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"")
################################################################################
# Check Dependencies
################################################################################
################################## ROOT ######################################
include(${CMAKE_SOURCE_DIR}/cmake/ROOTSetup.cmake)
################################# HEPMC ######################################
include(${CMAKE_SOURCE_DIR}/cmake/HepMC.cmake)
+############################### HepMCNuEvt ###################################
+include(${CMAKE_SOURCE_DIR}/cmake/HepMCNuEvtSetup.cmake)
############################ Reweight Engines ################################
include(${CMAKE_SOURCE_DIR}/cmake/ReweightEnginesSetup.cmake)
############################ Other Generators ################################
include(${CMAKE_SOURCE_DIR}/cmake/GiBUUSetup.cmake)
if(USE_NUANCE)
LIST(APPEND EXTRA_CXX_FLAGS -D__NUANCE_ENABLED__)
endif()
################################# Pythia6/8 ####################################
include(${CMAKE_SOURCE_DIR}/cmake/pythia6Setup.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pythia8Setup.cmake)
################################# gperftools ###################################
include(${CMAKE_SOURCE_DIR}/cmake/gperfSetup.cmake)
if(NOT NOTEST)
enable_testing()
endif()
SET(GENERATOR_SUPPORT)
foreach(gen NEUT;NuWro;GENIE;GiBUU;NUANCE)
if(USE_${gen})
SET(GENERATOR_SUPPORT "${GENERATOR_SUPPORT}${gen} ")
endif()
endforeach(gen)
cmessage(STATUS "Generator Input Support: ${GENERATOR_SUPPORT}")
set(MINCODE
Routines
FCN)
set(CORE
MCStudies
FitBase
Config
Logger
InputHandler
Splines
Utils
Statistical
#Devel
Smearceptance
)
LIST(APPEND ALLEXPERIMENTS
ANL
ArgoNeuT
BEBC
BNL
Electron
FNAL
GGM
K2K
MINERvA
MicroBooNE
MiniBooNE
SciBooNE
T2K)
foreach(exp ${ALLEXPERIMENTS})
if(NOT NO_${exp})
LIST(APPEND EXPERIMENTS_TO_BUILD ${exp})
else()
LIST(REVERSE EXTRA_CXX_FLAGS)
LIST(APPEND EXTRA_CXX_FLAGS -D__NO_${exp}__)
LIST(REVERSE EXTRA_CXX_FLAGS)
endif()
endforeach()
################################## COMPILER ####################################
include(${CMAKE_SOURCE_DIR}/cmake/c++CompilerSetup.cmake)
################################### doxygen ###################################
include(${CMAKE_SOURCE_DIR}/cmake/docsSetup.cmake)
################################################################################
set(MINIMUM_INCLUDE_DIRECTORIES)
LIST(APPEND MINIMUM_INCLUDE_DIRECTORIES
${RWENGINE_INCLUDE_DIRECTORIES}
${CMAKE_SOURCE_DIR}/src/FitBase
${CMAKE_SOURCE_DIR}/src/Reweight
${CMAKE_SOURCE_DIR}/src/InputHandler
${CMAKE_SOURCE_DIR}/src/Config
${CMAKE_SOURCE_DIR}/src/Logger
${CMAKE_SOURCE_DIR}/src/Statistical
${CMAKE_SOURCE_DIR}/src/Splines
${CMAKE_SOURCE_DIR}/src/Utils)
#Not yet capable of just building without the rwdirs.
#if(USE_REWEIGHT)
LIST(APPEND MINIMUM_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/src/Reweight)
LIST(APPEND CORE Reweight)
#endif()
cmessage(DEBUG "Base include directories: ${MINIMUM_INCLUDE_DIRECTORIES}")
set(EXP_INCLUDE_DIRECTORIES)
foreach(edir ${EXPERIMENTS_TO_BUILD})
LIST(APPEND EXP_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src/${edir})
endforeach()
cmessage(DEBUG "Included experiments: ${EXP_INCLUDE_DIRECTORIES}")
foreach(mdir ${MINCODE})
cmessage (DEBUG "Configuring directory: src/${mdir}")
add_subdirectory(src/${mdir})
endforeach()
foreach(edir ${EXPERIMENTS_TO_BUILD})
cmessage (DEBUG "Configuring directory: src/${edir}")
add_subdirectory(src/${edir})
endforeach()
foreach(cdir ${CORE})
cmessage (DEBUG "Configuring directory: src/${cdir}")
add_subdirectory(src/${cdir})
endforeach()
cmessage(DEBUG "Module targets: ${MODULETargets}")
LIST(APPEND MODULETargets -Wl,--end-group)
LIST(REVERSE MODULETargets)
LIST(APPEND MODULETargets -Wl,--start-group)
LIST(REVERSE MODULETargets)
add_subdirectory(app)
add_subdirectory(src/Tests)
configure_file(cmake/setup.sh.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" DESTINATION
${CMAKE_INSTALL_PREFIX})
configure_file(cmake/MakeBinaryBlob.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/MakeBinaryBlob" @ONLY)
install(PROGRAMS
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/MakeBinaryBlob" DESTINATION
bin)
if(USE_DYNSAMPLES)
SET(ALL_INCLUDES ${MINIMUM_INCLUDE_DIRECTORIES})
LIST(APPEND ALL_INCLUDES ${CMAKE_SOURCE_DIR}/src/Smearceptance)
LIST(APPEND ALL_INCLUDES ${EXP_INCLUDE_DIRECTORIES})
string(REPLACE ";" " -I" ALL_INCLUDES_STR "${ALL_INCLUDES}")
string(REPLACE "${CMAKE_SOURCE_DIR}/src" "${CMAKE_INSTALL_PREFIX}/include"
ALL_INCLUDES_STR "${ALL_INCLUDES_STR}")
cmessage(DEBUG ${CMAKE_DEPENDLIB_FLAGS})
string(REPLACE "-levent " "" CMAKE_DEPENDLIB_FLAGS_NEW ${CMAKE_DEPENDLIB_FLAGS})
set(CMAKE_DEPENDLIB_FLAGS ${CMAKE_DEPENDLIB_FLAGS_NEW})
cmessage(DEBUG ${CMAKE_DEPENDLIB_FLAGS})
string(REPLACE ";" " -l" ALL_MODULETARGETS_STR "${MODULETargets}")
string(REPLACE "-l-" "-" ALL_MODULETARGETS_STR "${ALL_MODULETARGETS_STR}")
configure_file(cmake/BuildDynamicSample.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample" @ONLY)
install(PROGRAMS
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample" DESTINATION
bin)
configure_file(cmake/BuildDynamicSmearcepter.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter" @ONLY)
install(PROGRAMS
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter" DESTINATION
bin)
endif()
install(PROGRAMS
"${PROJECT_SOURCE_DIR}/scripts/nuiscardgen" DESTINATION
bin)
install(PROGRAMS
"${PROJECT_SOURCE_DIR}/scripts/nuissamples" DESTINATION
bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION
${CMAKE_INSTALL_PREFIX})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/event_gen DESTINATION
${CMAKE_INSTALL_PREFIX})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/parameters DESTINATION
${CMAKE_INSTALL_PREFIX})
diff --git a/cmake/GENIESetup.cmake b/cmake/GENIESetup.cmake
index 4139f82..3102253 100644
--- a/cmake/GENIESetup.cmake
+++ b/cmake/GENIESetup.cmake
@@ -1,249 +1,249 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
# TODO
# check system for libxml2
# check whether we need the includes
# check if we can use a subset of the GENIE libraries
include(${CMAKE_SOURCE_DIR}/cmake/parseConfigApp.cmake)
################################################################################
# Check Dependencies
################################################################################
################################# GENIE ######################################
if(GENIE STREQUAL "")
cmessage(FATAL_ERROR "Variable GENIE is not defined. "
"The location of a pre-built GENIE install must be defined either as"
" $ cmake -DGENIE=/path/to/GENIE or as an environment variable"
" $ export GENIE=/path/to/GENIE")
endif()
execute_process(COMMAND genie-config --version
OUTPUT_VARIABLE GENIE_VER OUTPUT_STRIP_TRAILING_WHITESPACE)
cmessage(STATUS "genie_ver: ${GENIE_VER}")
if(GENIE_VER VERSION_GREATER 3.0.0)
set(GENIE_POST_R3 1)
string(REPLACE "." "" GENIE_VERSION ${GENIE_VER})
cmessage(STATUS "set genie_post_r3")
endif()
if(NOT GENIE_POST_R3)
LIST(APPEND EXTRA_CXX_FLAGS -DGENIE_PRE_R3)
cmessage(STATUS "setting genie_pre_r3 ${EXTRA_CXX_FLAGS}")
if(GENIE_EMPMEC_REWEIGHT)
cmessage(STATUS "Enable EMPMEC dials")
LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_EMP_MECRW_ENABLED)
endif()
else()
cmessage(STATUS "Enable EMPMEC dials")
LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_EMP_MECRW_ENABLED)
- if(DEFINED USE_GENIE_XSECMEC AND USE_GENIE_XSECMEC)
+ if(USE_GENIE_XSECMEC)
LIST(APPEND EXTRA_CXX_FLAGS -DUSE_GENIE_XSECMEC)
endif()
endif()
execute_process (COMMAND genie-config
--topsrcdir OUTPUT_VARIABLE GENIE_INCLUDES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
#Allows for external override in the case where genie-config lies.
if(NOT DEFINED GENIE_LIB_DIR OR GENIE_LIB_DIR STREQUAL "")
#This looks like it should call libdir, but it strips the argument with -L from the response of --libs
GETLIBDIRS(genie-config --libs GENIE_LIB_DIR)
endif()
GETLIBS(genie-config --libs GENIE_LIBS)
cmessage(STATUS "GENIE version : ${GENIE_VERSION}")
cmessage(STATUS "GENIE libdir : ${GENIE_LIB_DIR}")
cmessage(STATUS "GENIE libs : ${GENIE_LIBS}")
string(REGEX MATCH "ReinSeghal" WASMATCHED ${GENIE_LIBS})
if(WASMATCHED AND GENIE_VERSION STREQUAL "210")
set(GENIE_SEHGAL ${GENIE_LIBS})
STRING(REPLACE "ReinSeghal" "ReinSehgal" GENIE_LIBS ${GENIE_SEHGAL})
cmessage(DEBUG "Fixed inconsistency in library naming: ${GENIE_LIBS}")
endif()
if(NOT USE_REWEIGHT)
SET(USING_GENIE_RW FALSE)
elseif(NOT GENIE_POST_R3)
LIST(FIND GENIE_LIBS GReWeight FOUND_GENIE_RW)
if(FOUND_GENIE_RW EQUAL -1)
cmessage(DEBUG "Did NOT find ReWeight library. Here are libs: ${GENIE_LIBS}")
SET(USING_GENIE_RW FALSE)
else()
SET(USING_GENIE_RW TRUE)
endif()
elseif(DEFINED GENIE_REWEIGHT AND NOT GENIE_REWEIGHT STREQUAL "")
LIST(FIND GENIE_LIBS GRwFwk FOUND_GENIE_RW)
if(FOUND_GENIE_RW EQUAL -1)
LIST(APPEND GENIE_LIBS GRwClc GRwFwk GRwIO)
cmessage(DEBUG "Force added ReWeight library. Here are libs: ${GENIE_LIBS}")
SET(USING_GENIE_RW TRUE)
else()
SET(USING_GENIE_RW FALSE)
endif()
endif()
if(USING_GENIE_RW)
cmessage(STATUS "Using GENIE ReWeight library.")
else()
cmessage(STATUS "Building without GENIE ReWeight support.")
endif()
LIST(APPEND GENIE_LIBS -Wl,--end-group )
LIST(REVERSE GENIE_LIBS)
LIST(APPEND GENIE_LIBS -Wl,--start-group -Wl,--no-as-needed )
LIST(REVERSE GENIE_LIBS)
cmessage(DEBUG "GENIE_LIBS: ${GENIE_LIBS}")
################################ LHAPDF ######################################
if(LHAPDF_LIB STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPDF_LIB is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_LIB=/path/to/LHAPDF_libraries or as an environment variable $ export LHAPDF_LIB=/path/to/LHAPDF_libraries")
endif()
if(LHAPDF_INC STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPDF_INC is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_INC=/path/to/LHAPDF_includes or as an environment variable $ export LHAPDF_INC=/path/to/LHAPDF_includes")
endif()
if(LHAPATH STREQUAL "")
cmessage(FATAL_ERROR "Variable LHAPATH is not defined. The location of a the LHAPATH directory must be defined either as $ cmake -DLHAPATH=/path/to/LHAPATH or as an environment variable $ export LHAPATH=/path/to/LHAPATH")
endif()
################################ LIBXML ######################################
if(LIBXML2_LIB STREQUAL "")
GETLIBDIR(xml2-config --libs LIBXML2_LIB IGNORE_EMPTY_RESPONSE)
if(LIBXML2_LIB STREQUAL "")
message(WARNING "Variable LIBXML2_LIB is not defined, as xml2-config was found and didn't report a library include path, it is likely that libxml2.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLIBXML2_LIB=/path/to/LIBXML2_libraries or as an environment variable LIBXML2_LIB.")
endif()
endif()
if(LIBXML2_INC STREQUAL "")
GETINCDIR(xml2-config --cflags LIBXML2_INC IGNORE_EMPTY_RESPONSE)
if(LIBXML2_INC STREQUAL "")
message(WARNING "Variable LIBXML2_INC is not defined, as xml2-config was found and didn't report an include path, it is likely that libxml2.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLIBXML2_INC=/path/to/LIBXML2_includes or as an environment variable LIBXML2_INC.")
endif()
endif()
############################### log4cpp ######################################
if(LOG4CPP_LIB STREQUAL "")
GETLIBDIR(log4cpp-config --libs LOG4CPP_LIB IGNORE_EMPTY_RESPONSE)
if(LOG4CPP_LIB STREQUAL "")
message(WARNING "Variable LOG4CPP_LIB is not defined, as xml2-config was found and didn't report a library include path, it is likely that liblog4cpp.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLOG4CPP_LIB=/path/to/LOG4CPP_libraries or as an environment variable LOG4CPP_LIB.")
endif()
endif()
if(LOG4CPP_INC STREQUAL "")
GETINCDIR(log4cpp-config --cflags LOG4CPP_INC IGNORE_EMPTY_RESPONSE)
if(LOG4CPP_INC STREQUAL "")
message(WARNING "Variable LOG4CPP_LIB is not defined, as xml2-config was found and didn't report an include path, it is likely that log4cpp headers can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLOG4CPP_INC=/path/to/LOG4CPP_includes or as an environment variable LOG4CPP_INC.")
endif()
endif()
################################################################################
# Set the compiler defines
LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_ENABLED__ -D__GENIE_VERSION__=${GENIE_VERSION})
LIST(APPEND EXTRA_LIBS ${GENIE_LIBS})
############################### GSL ######################################
if(GENIE_POST_R3)
if(GSL_LIB STREQUAL "")
GETLIBDIR(gsl-config --libs GSL_LIB)
if(GSL_LIB STREQUAL "")
message(FATAL_ERROR "Variable GSL_LIB is not defined and could not be found with gsl-config. The location of a pre-built gsl install must be defined either as $ cmake -DGSL_LIB=/path/to/GSL_libraries or as an environment variable $ export GSL_LIB=/path/to/GSL_libraries")
endif()
endif()
if(GSL_INC STREQUAL "")
GETINCDIR(gsl-config --cflags GSL_INC)
if(GSL_INC STREQUAL "")
message(FATAL_ERROR "Variable GSL_INC is not defined and could not be found with gsl-config. The location of a pre-built gsl install must be defined either as $ cmake -DGSL_INC=/path/to/GSL_includes or as an environment variable $ export GSL_INC=/path/to/GSL_includes")
endif()
endif()
GETLIBS(gsl-config --libs GSL_LIB_LIST)
if(USING_GENIE_RW AND GENIE_REWEIGHT STREQUAL "")
message(FATAL_ERROR "Variable GENIE_REWEIGHT is not defined. When using GENIE v3+, we require the reweight product to be built and accessible via the environment variable GENIE_REWEIGHT")
endif()
endif()
################################################################################
LIST(APPEND EXTRA_LIBS LHAPDF xml2 log4cpp)
LIST(APPEND EXTRA_LINK_DIRS
${GENIE_LIB_DIR}
${LHAPDF_LIB}
${LOG4CPP_LIB})
# Append only if we have found GENIE ReWeight
if(NOT GENIE_POST_R3)
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES
${GENIE_INCLUDES_DIR}
${GENIE_INCLUDES_DIR}/GHEP
${GENIE_INCLUDES_DIR}/Ntuple)
if(USING_GENIE_RW)
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_INCLUDES_DIR}/ReWeight)
endif()
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES
${GENIE_INCLUDES_DIR}/Apps
${GENIE_INCLUDES_DIR}/FluxDrivers
${GENIE_INCLUDES_DIR}/EVGDrivers
${LHAPDF_INC}
${LIBXML2_INC}
${LOG4CPP_INC})
else()
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES
${GENIE_INCLUDES_DIR})
if(USING_GENIE_RW)
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_REWEIGHT}/src)
endif()
LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GSL_INC}
${LHAPDF_INC}
${LIBXML2_INC}
${LOG4CPP_INC})
if(USING_GENIE_RW)
LIST(APPEND EXTRA_LINK_DIRS
${GENIE_REWEIGHT}/lib)
endif()
LIST(APPEND EXTRA_LINK_DIRS
${GSL_LIB}
)
LIST(APPEND EXTRA_LIBS ${GSL_LIB_LIST})
endif()
if(USE_PYTHIA8)
set(NEED_PYTHIA8 TRUE)
set(NEED_ROOTPYTHIA8 TRUE)
else()
set(NEED_PYTHIA6 TRUE)
set(NEED_ROOTPYTHIA6 TRUE)
endif()
set(NEED_ROOTEVEGEN FALSE)
SET(USE_GENIE TRUE CACHE BOOL "Whether to enable GENIE (reweight) support. Requires external libraries. " FORCE)
diff --git a/cmake/HepMCNuEvtSetup.cmake b/cmake/HepMCNuEvtSetup.cmake
new file mode 100644
index 0000000..4454216
--- /dev/null
+++ b/cmake/HepMCNuEvtSetup.cmake
@@ -0,0 +1,23 @@
+if(USE_HEPMCNUEVT)
+# Get libdir from
+ execute_process (COMMAND HepMC3-config --includedir
+ OUTPUT_VARIABLE HEPMC_INCDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process (COMMAND HepMC3-config --libdir
+ OUTPUT_VARIABLE HEPMC_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ execute_process (COMMAND HepMC3-config --prefix
+ OUTPUT_VARIABLE HEPMCROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ include_directories($ENV{HEPMCNUEVTTOOLSROOT}/include)
+ LIST(APPEND EXTRA_LINK_DIRS $ENV{HEPMCNUEVTTOOLSROOT}/lib)
+ LIST(APPEND EXTRA_LIBS HepMCNuEvtTools)
+
+ include_directories(${HEPMC_INCDIR})
+ LIST(APPEND EXTRA_LINK_DIRS ${HEPMC_LIBDIR})
+ LIST(APPEND EXTRA_LIBS HepMC3 HepMC3rootIO)
+
+ set(HEPMCNUEVTTOOLSROOT $ENV{HEPMCNUEVTTOOLSROOT})
+ set(USE_HEPMCNUEVT TRUE)
+
+endif()
diff --git a/cmake/ReweightEnginesSetup.cmake b/cmake/ReweightEnginesSetup.cmake
index 31dc580..3efc7c8 100644
--- a/cmake/ReweightEnginesSetup.cmake
+++ b/cmake/ReweightEnginesSetup.cmake
@@ -1,97 +1,101 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
if(NOT USE_REWEIGHT)
LIST(APPEND EXTRA_CXX_FLAGS -D__NO_REWEIGHT__)
endif()
################################## T2K ######################################
if(USE_T2K)
include(${CMAKE_SOURCE_DIR}/cmake/T2KSetup.cmake)
cmessage(STATUS "Using T2K Reweight engine.")
set(USE_T2K TRUE CACHE BOOL "Whether to enable T2KReWeight support. Requires external libraries. " FORCE)
endif()
################################## NIWG ######################################
if(USE_NIWG)
include(${CMAKE_SOURCE_DIR}/cmake/NIWGSetup.cmake)
cmessage(STATUS "Using NIWG Reweight engine.")
set(USE_NIWG TRUE CACHE BOOL "Whether to enable (T2K) NIWG ReWeight support. Requires external libraries. " FORCE)
endif()
################################## MINERvA ######################################
if(USE_MINERvA_RW)
include(${CMAKE_SOURCE_DIR}/cmake/MINERvASetup.cmake)
cmessage(STATUS "Using MINERvA Reweight engine.")
set(USE_MINERvA_RW TRUE CACHE BOOL "Whether to enable MINERvA ReWeight support. " FORCE)
endif()
################################## NEUT ######################################
if(USE_NEUT)
include(${CMAKE_SOURCE_DIR}/cmake/NEUTSetup.cmake)
cmessage(STATUS "Using NEUT Reweight engine.")
set(USE_NEUT TRUE CACHE BOOL "Whether to enable NEUT (reweight) support. Requires external libraries. " FORCE)
endif()
################################# NuWro ######################################
if(USE_NuWro)
include(${CMAKE_SOURCE_DIR}/cmake/NuWroSetup.cmake)
cmessage(STATUS "Using NuWro Reweight engine.")
set(USE_NuWro TRUE CACHE BOOL "Whether to enable NuWro support. " FORCE)
endif()
################################## GENIE #####################################
if(USE_GENIE)
include(${CMAKE_SOURCE_DIR}/cmake/GENIESetup.cmake)
cmessage(STATUS "Using GENIE.")
set(USE_GENIE TRUE CACHE BOOL "Whether to enable GENIE support. Requires external libraries. " FORCE)
endif()
################################################################################
################################ NOvARwgt ####################################
if(USE_NOvARwgt)
include(${CMAKE_SOURCE_DIR}/cmake/NOvARwgtSetup.cmake)
cmessage(STATUS "Using NOvARwgt Reweight engine.")
set(USE_NOvARwgt TRUE CACHE BOOL "Whether to enable NOvARwgt (reweight) support. Requires external libraries. " FORCE)
endif()
################################################################################
-
+if(USE_DUNERWT)
+ include(${CMAKE_SOURCE_DIR}/cmake/nusystematicsSetup.cmake)
+ cmessage(STATUS "Using NOvARwgt Reweight engine.")
+ set(USE_DUNERWT TRUE CACHE BOOL "Whether to enable DUNERwt (reweight) support. Requires external libraries. " FORCE)
+endif()
################################ Prob3++ ####################################
include(${CMAKE_SOURCE_DIR}/cmake/Prob3++Setup.cmake)
################################################################################
cmessage(STATUS "Reweight engine include directories: ${RWENGINE_INCLUDE_DIRECTORIES}")
if(NEED_ROOTEVEGEN)
cmessage(STATUS "Require ROOT eve generation libraries")
LIST(REVERSE ROOT_LIBS)
LIST(APPEND ROOT_LIBS
Gui
Ged
Geom
TreePlayer
EG
Eve)
LIST(REVERSE ROOT_LIBS)
endif()
if(NEED_ROOTPYTHIA6)
cmessage(STATUS "Require ROOT Pythia6 libraries")
LIST(APPEND ROOT_LIBS
EGPythia6)
endif()
LIST(APPEND EXTRA_LIBS ${ROOT_LIBS})
diff --git a/cmake/cacheVariables.cmake b/cmake/cacheVariables.cmake
index 18bf67f..cce141d 100644
--- a/cmake/cacheVariables.cmake
+++ b/cmake/cacheVariables.cmake
@@ -1,240 +1,245 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
function(CheckAndSetDefaultEnv VARNAME DEFAULT CACHETYPE DOCSTRING ENVNAME)
#cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.")
if(NOT DEFINED ${VARNAME})
if(DEFINED ENV{${ENVNAME}} AND NOT $ENV{${ENVNAME}} STREQUAL "")
set(${VARNAME} $ENV{${ENVNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
cmessage(DEBUG " Read ${VARNAME} from ENVVAR ${ENVNAME} as $ENV{${ENVNAME}}.")
else()
set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING})
endif()
else()
set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
unset(${VARNAME})
endif()
cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.")
endfunction()
function(CheckAndSetDefaultCache VARNAME DEFAULT CACHETYPE DOCSTRING)
# cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.")
if(NOT DEFINED ${VARNAME})
set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING})
else()
set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING})
unset(${VARNAME})
endif()
cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.")
endfunction()
function(CheckAndSetDefault VARNAME DEFAULT)
# cmessage(DEBUG "Trying to assign variable ${VARNAME}.")
if(NOT DEFINED ${VARNAME})
set(${VARNAME} ${DEFAULT} PARENT_SCOPE)
set(${VARNAME} ${DEFAULT})
endif()
cmessage(CACHE "--Set variable: \"${VARNAME}\" to \"${${VARNAME}}\".")
endfunction()
CheckAndSetDefaultCache(VERBOSE TRUE BOOL "Whether to configure loudly.")
set (CMAKE_SKIP_BUILD_RPATH TRUE)
#Changes default install path to be a subdirectory of the build dir.
#Can set build dir at configure time with -DCMAKE_INSTALL_PREFIX=/install/path
if(CMAKE_INSTALL_PREFIX STREQUAL "" OR CMAKE_INSTALL_PREFIX STREQUAL
"/usr/local")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
elseif(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE DEBUG)
elseif(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE DEBUG)
endif()
CheckAndSetDefaultCache(EXTRA_SETUP_SCRIPT "" PATH "The path to an extra script to inject into the NUISANCE setup script. <>")
CheckAndSetDefaultCache(USE_MINIMIZER TRUE BOOL "Whether we are using the ROOT minimization libraries. ")
CheckAndSetDefaultCache(USE_REWEIGHT TRUE BOOL "Whether we are expect to be able to build the reweighting libraries of enabled generators. ")
CheckAndSetDefaultCache(USE_ROOT6 FALSE INTERNAL "Whether we are using the ROOT 6. ")
+CheckAndSetDefaultCache(USE_HEPMCNUEVT FALSE BOOL "Whether to enable HepMC3 input support. ")
+
+CheckAndSetDefaultCache(USE_DUNERWT FALSE BOOL "Whether to enable DUNE Reweight support. ")
+
CheckAndSetDefaultCache(USE_HEPMC FALSE BOOL "Whether to enable HepMC input support. ")
CheckAndSetDefaultEnv(HEPMC "" PATH "Path to HepMC source tree root directory. Overrides environment variable \$HEPMC <>" HEPMC)
CheckAndSetDefaultCache(HEPMC_MOMUNIT "GEV" STRING "HepMC momentum units [MEV|GEV]. ")
CheckAndSetDefaultCache(HEPMC_LENUNIT "CM" STRING "HepMC momentum units [MM|CM]. ")
CheckAndSetDefaultCache(HEPMC_USED_EP FALSE INTERNAL "Whether we built HepMC or not. ")
CheckAndSetDefaultCache(USE_NEUT FALSE BOOL "Whether to enable NEUT (reweight) support. Requires external libraries. ")
CheckAndSetDefaultEnv(NEUT_VERSION FALSE STRING "NEUT version string, e.g. 5.4.0. <5.4.0>" NEUT_VERSION)
CheckAndSetDefaultEnv(NEUT_ROOT "" PATH "Path to NEUT source tree root directory. Overrides environment variable \$NEUT_ROOT <>" NEUT_ROOT)
CheckAndSetDefaultEnv(CERN "" PATH "Path to CERNLIB source tree root directory that NEUT was built against. Overrides environment variable \$CERN <>" CERN)
CheckAndSetDefaultEnv(CERN_LEVEL "" STRING "CERNLIB Library version. Overrides environment variable \$CERN_LEVEL <>" CERN_LEVEL)
CheckAndSetDefaultCache(USE_NuWro FALSE BOOL "Whether to enable NuWro support. ")
CheckAndSetDefaultEnv(NUWRO "" PATH "Path to NuWro source tree root directory. Overrides environment variable \$NUWRO <>" NUWRO)
CheckAndSetDefaultEnv(NUWRO_INC "" PATH "Path to NuWro installed includes directory, needs to contain \"params_all.h\". Overrides environment variable \$NUWRO_INC <>" NUWRO_INC)
CheckAndSetDefaultCache(NUWRO_INPUT_FILE "" FILEPATH "Path to an input NuWro event vector, which can be used to build NuWro i/o libraries. <>")
CheckAndSetDefaultCache(NUWRO_BUILT_FROM_FILE FALSE INTERNAL "Whether the NuWro libraries were built by NUISANCE. ")
CheckAndSetDefaultCache(USE_NuWro_RW FALSE BOOL "Whether to try and build support for NuWro reweighting. ")
CheckAndSetDefaultCache(USE_NuWro_SRW_Event FALSE BOOL "Whether to use cut down NuWro reweight event format. Requires NuWro reweight. ")
CheckAndSetDefaultCache(USE_GENIE FALSE BOOL "Whether to enable GENIE support. Requires external libraries. ")
CheckAndSetDefaultCache(GENIE_VERSION "AUTO" STRING "GENIE Version ")
CheckAndSetDefaultEnv(GENIE "" PATH "Path to GENIE source tree root directory. Overrides environment variable \$GENIE <>" GENIE)
CheckAndSetDefaultEnv(GENIE_REWEIGHT "" PATH "Path to GENIE ReWeight directory. Only relevant for GENIE v3+. Overrides environment variable \$GENIE_REWEIGHT <>" GENIE_REWEIGHT)
CheckAndSetDefaultCache(GENIE_EMPMEC_REWEIGHT FALSE BOOL "Whether to use GENIE EMP MEC reweight (requires custom GENIE) ")
+CheckAndSetDefaultCache(USE_GENIE_XSECMEC FALSE BOOL "Whether to use GENIE MEC reweight (requires custom GENIE) ")
CheckAndSetDefaultEnv(LHAPDF_LIB "" PATH "Path to pre-built LHAPDF libraries. Overrides environment variable \$LHAPDF_LIB. <>" LHAPDF_LIB)
CheckAndSetDefaultEnv(LHAPDF_INC "" PATH "Path to installed LHAPDF headers. Overrides environment variable \$LHAPDF_INC. <>" LHAPDF_INC)
CheckAndSetDefaultEnv(LHAPATH "" PATH "Path to LHA PDF inputs. Overrides environment variable \$LHAPATH. <>" LHAPATH)
CheckAndSetDefaultEnv(LIBXML2_LIB "" PATH "Path to pre-built LIBXML2 libraries. Overrides environment variable \$LIBXML2_LIB. <>" LIBXML2_LIB)
CheckAndSetDefaultEnv(LIBXML2_INC "" PATH "Path to installed LIBXML2 headers. Overrides environment variable \$LIBXML2_INC. <>" LIBXML2_INC)
CheckAndSetDefaultEnv(LOG4CPP_LIB "" PATH "Path to pre-built LOG4CPP libraries. Overrides environment variable \$LOG4CPP_LIB. <>" LOG4CPP_LIB)
CheckAndSetDefaultEnv(LOG4CPP_INC "" PATH "Path to installed LOG4CPP headers. Overrides environment variable \$LOG4CPP_INC. <>" LOG4CPP_INC)
CheckAndSetDefaultEnv(GSL_LIB "" PATH "Path to pre-built gsl libraries. Overrides environment variable \$GSL_LIB. <>" GSL_LIB)
CheckAndSetDefaultEnv(GSL_INC "" PATH "Path to installed gsl headers. Overrides environment variable \$GSL_INC. <>" GSL_INC)
CheckAndSetDefaultCache(USE_T2K FALSE BOOL "Whether to enable T2KReWeight support. Requires external libraries. ")
CheckAndSetDefaultEnv(T2KREWEIGHT "" PATH "Path to installed T2KREWEIGHTReWeight. Overrides environment variable \$T2KREWEIGHT. <>" T2KREWEIGHT)
CheckAndSetDefaultCache(USE_NIWG FALSE BOOL "Whether to enable (T2K) NIWG ReWeight support. Requires external libraries. ")
CheckAndSetDefaultEnv(NIWG_ROOT "" PATH "Path to installed NIWGReWeight. Overrides environment variable \$NIWG. <>" NIWG)
CheckAndSetDefaultCache(USE_MINERvA_RW FALSE BOOL "Whether to enable MINERvA ReWeight support. ")
CheckAndSetDefaultCache(USE_NOvARwgt FALSE BOOL "Whether to enable NOvA ReWeight support. ")
CheckAndSetDefaultEnv(NOVARWGT "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$NOVARWGT <>" NOVARWGT)
CheckAndSetDefaultEnv(PYTHIA6 "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>" PYTHIA6)
CheckAndSetDefaultEnv(PYTHIA8 "" PATH "Path to directory containing libPythia8.so. Overrides environment variable \$PYTHIA8 <>" PYTHIA8)
CheckAndSetDefaultCache(USE_PYTHIA8 FALSE BOOL "Whether to enable PYTHIA8 event support. ")
CheckAndSetDefaultCache(USE_GiBUU TRUE BOOL "Whether to enable GiBUU event support. ")
CheckAndSetDefaultCache(BUILD_GiBUU FALSE BOOL "Whether to build supporting GiBUU event tools along with a patched version of GiBUU. ")
CheckAndSetDefaultCache(USE_NUANCE TRUE BOOL "Whether to enable NUANCE event support. ")
CheckAndSetDefaultCache(USE_PROB3PP FALSE BOOL "Whether to download and compile in Prob3++ support. ")
CheckAndSetDefaultCache(NO_EXTERNAL_UPDATE FALSE BOOL "Whether to perform the update target for external dependencies. Note this may produce errors for CMake < 3.8 where a bug was fixed for the feature that this option invokes. ")
CheckAndSetDefaultCache(USE_GPERFTOOLS FALSE BOOL "Whether to compile in google performance tools. ")
CheckAndSetDefault(NEED_PYTHIA6 FALSE)
CheckAndSetDefault(NEED_PYTHIA8 FALSE)
CheckAndSetDefault(NEED_ROOTEVEGEN FALSE)
CheckAndSetDefault(NEED_ROOTPYTHIA6 FALSE)
CheckAndSetDefaultCache(USE_OMP FALSE BOOL "Whether to enable multicore features (there currently are none...). ")
CheckAndSetDefaultCache(USE_DYNSAMPLES TRUE BOOL "Whether to enable the dynamic sample loader. ")
CheckAndSetDefault(NO_EXPERIMENTS FALSE)
cmessage(STATUS "NO_EXPERIMENTS: ${NO_EXPERIMENTS}")
CheckAndSetDefaultCache(NO_ANL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ANL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_ArgoNeuT ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ArgoNeuT samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_BEBC ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BEBC samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_BNL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BNL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_FNAL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build FNAL samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_GGM ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build GGM samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_K2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build K2K samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_MINERvA ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MINERvA samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_MiniBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MiniBooNE samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_T2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build T2K samples. <-DNO_EXPERIMENTS=FALSE>")
CheckAndSetDefaultCache(NO_SciBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build SciBooNE samples. <-DNO_EXPERIMENTS=FALSE>")
function(SAYVARS)
LIST(APPEND VARS
USE_HEPMC
HEPMC
HEPMC_MOMUNIT
HEPMC_LENUNIT
HEPMC_USED_EP
USE_NEUT
NEUT_VERSION
NEUT_ROOT
CERN
CERN_LEVEL
USE_NuWro
NUWRO
NUWRO_INC
NUWRO_INPUT_FILE
NUWRO_BUILT_FROM_FILE
USE_GENIE
GENIE_VERSION
GENIE
GENIE_REWEIGHT
LHAPDF_LIB
LHAPDF_INC
LHAPATH
LIBXML2_LIB
LIBXML2_INC
LOG4CPP_LIB
LOG4CPP_INC
GSL_LIB
GSL_INC
PYTHIA6
PYTHIA8
USE_PYTHIA8
USE_T2K
T2KREWEIGHT
USE_NIWG
NIWG_ROOT
USE_MINERvA_RW
USE_NOvARwgt
NOVARWGT
USE_GiBUU
BUILD_GiBUU
USE_NUANCE
USE_PROB3PP
NO_EXTERNAL_UPDATE
USE_GPERFTOOLS
NO_EXPERIMENTS
NO_ANL
NO_ArgoNeuT
NO_BEBC
NO_BNL
NO_FNAL
NO_GGM
NO_K2K
NO_MINERvA
NO_MiniBooNE
NO_T2K
NO_SciBooNE)
foreach(v ${VARS})
if(DEFINED ${v})
cmessage(DEBUG "VARIABLE: \"${v}\" = \"${${v}}\"")
endif()
endforeach(v)
endfunction()
diff --git a/cmake/nusystematicsSetup.cmake b/cmake/nusystematicsSetup.cmake
new file mode 100644
index 0000000..6e4f9af
--- /dev/null
+++ b/cmake/nusystematicsSetup.cmake
@@ -0,0 +1,37 @@
+# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+
+################################################################################
+# This file is part of NUISANCE.
+#
+# NUISANCE 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 3 of the License, or
+# (at your option) any later version.
+#
+# NUISANCE 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 NUISANCE. If not, see .
+################################################################################
+
+if(NUSYSTROOT STREQUAL "")
+ cmessage(FATAL_ERROR "Variable NUSYSTROOT is not defined. Either configure with -DNUSYSTROOT or \"\$ export NUSYSTROOT=/path/to/nusystematics\". This must be set to point to a prebuilt NuSystematics instance.")
+endif()
+
+if(SYSTTOOLSROOT STREQUAL "")
+ cmessage(FATAL_ERROR "Variable SYSTTOOLSROOT is not defined. Either configure with -DSYSTTOOLSROOT or \"\$ export SYSTTOOLSROOT=/path/to/systematicstools\". This must be set to point to a prebuilt ART Systematics Tools instance.")
+endif()
+
+LIST(APPEND EXTRA_CXX_FLAGS -D__DUNERWT_ENABLED__ -DNO_ART -std=c++1y -Wno-deprecated-declarations -Wno-deprecated)
+
+LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUSYSTROOT}/include ${SYSTTOOLSROOT}/include)
+
+LIST(APPEND EXTRA_LINK_DIRS ${NUSYSTROOT}/lib ${SYSTTOOLSROOT}/lib)
+LIST(APPEND EXTRA_LIBS nusystematics_systproviders
+ systematicstools_interface
+ systematicstools_interpreters
+ systematicstools_systproviders
+ systematicstools_utility)
diff --git a/cmake/setup.sh.in b/cmake/setup.sh.in
index caf39bd..eb10e30 100644
--- a/cmake/setup.sh.in
+++ b/cmake/setup.sh.in
@@ -1,165 +1,170 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
#!/bin/sh
### Adapted from https://unix.stackexchange.com/questions/4965/keep-duplicates-out-of-path-on-source
function add_to_PATH () {
for d; do
d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links
if [ -z "$d" ]; then continue; fi # skip nonexistent directory
if [ "$d" == "/usr/bin" ] || [ "$d" == "/usr/bin64" ] || [ "$d" == "/usr/local/bin" ] || [ "$d" == "/usr/local/bin64" ]; then
case ":$PATH:" in
*":$d:"*) :;;
*) export PATH=$PATH:$d;;
esac
else
case ":$PATH:" in
*":$d:"*) :;;
*) export PATH=$d:$PATH;;
esac
fi
done
}
function add_to_LD_LIBRARY_PATH () {
for d; do
d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links
if [ -z "$d" ]; then continue; fi # skip nonexistent directory
if [ "$d" == "/usr/lib" ] || [ "$d" == "/usr/lib64" ] || [ "$d" == "/usr/local/lib" ] || [ "$d" == "/usr/local/lib64" ]; then
case ":$LD_LIBRARY_PATH:" in
*":$d:"*) :;;
*) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$d;;
esac
else
case ":$LD_LIBRARY_PATH:" in
*":$d:"*) :;;
*) export LD_LIBRARY_PATH=$d:$LD_LIBRARY_PATH;;
esac
fi
done
}
if [ "@EXTRA_SETUP_SCRIPT@" ]; then
if [ ! -e @EXTRA_SETUP_SCRIPT@ ]; then
echo "[WARN]: Extra setup script \"@EXTRA_SETUP_SCRIPT@\" requested, but could not be found. Skipping..."
else
echo "[INFO]: Sourcing extra setup from \"@EXTRA_SETUP_SCRIPT@\"."
. @EXTRA_SETUP_SCRIPT@
fi
fi
add_to_PATH "@CMAKE_INSTALL_PREFIX@/bin"
add_to_LD_LIBRARY_PATH "@CMAKE_INSTALL_PREFIX@/lib"
if [ ! "${ROOTSYS}" ]; then
echo "[INFO]: Sourcing ROOT from: @CMAKE_ROOTSYS@"
source "@CMAKE_ROOTSYS@/bin/thisroot.sh"
fi
if [ "@USE_T2K@" != "FALSE" ]; then
echo "[INFO]: Adding T2K paths to the environment."
export T2KREWEIGHT=@T2KREWEIGHT@
add_to_LD_LIBRARY_PATH "@T2KREWEIGHT@/lib"
fi
if [ "@USE_NIWG@" != "FALSE" ]; then
echo "[INFO]: Adding NIWG paths to the environment."
export NIWG=@NIWG_ROOT@
export NIWGREWEIGHT_INPUTS=@NIWG_ROOT@/inputs
add_to_LD_LIBRARY_PATH "@NIWG_ROOT@"
fi
if [ "@USE_NEUT@" != "FALSE" ]; then
echo "[INFO]: Adding NEUT library paths to the environment."
export NEUT_ROOT=@NEUT_ROOT@
export CERN=@CERN@
export CERN_LEVEL=@CERN_LEVEL@
add_to_LD_LIBRARY_PATH "${NEUT_LIB_DIR}" "${NEUT_ROOT}/src/reweight"
fi
if [ "@USE_NuWro@" != "FALSE" ]; then
if [ "@NUWRO_BUILT_FROM_FILE@" == "FALSE" ]; then
echo "[INFO]: Adding NuWro library paths to the environment."
export NUWRO="@NUWRO@"
add_to_PATH "@NUWRO@/bin"
add_to_LD_LIBRARY_PATH "@NUWRO@/build/@CMAKE_SYSTEM_NAME@/lib"
if [ "@NUWRO_INC@" ]; then
export NUWRO_INC=@NUWRO_INC@
fi
else
echo "[INFO]: NuWro support included from input event file."
fi
fi
if [ "@NEED_PYTHIA6@" != "FALSE" ]; then
echo "[INFO]: Adding PYTHIA6 library paths to the environment."
export PYTHIA6="@PYTHIA6@"
add_to_LD_LIBRARY_PATH "@PYTHIA6@"
fi
if [ "@USE_GENIE@" != "FALSE" ]; then
echo "[INFO]: Adding GENIE paths to the environment."
export GENIE="@GENIE@"
export LHAPDF_LIB="@LHAPDF_LIB@"
export LHAPDF_INC="@LHAPDF_INC@"
export LIBXML2_LIB="@LIBXML2_LIB@"
export LIBXML2_INC="@LIBXML2_INC@"
export LOG4CPP_LIB="@LOG4CPP_LIB@"
export LOG4CPP_INC="@LOG4CPP_INC@"
if [ "@LHAPATH@" ]; then
export LHAPATH="@LHAPATH@"
fi
add_to_PATH "@GENIE@/bin"
add_to_LD_LIBRARY_PATH "@GENIE@/lib" "@LHAPDF_LIB@" "@LIBXML2_LIB@" "@LOG4CPP_LIB@"
if [ "@GENIE_REWEIGHT@" ]; then
export GENIE_REWEIGHT="@GENIE_REWEIGHT@"
add_to_LD_LIBRARY_PATH "@GENIE_REWEIGHT@/lib"
fi
fi
if [ "@BUILD_GiBUU@" != "FALSE" ]; then
echo "[INFO]: Sourcing GiBUU tools."
source @CMAKE_BINARY_DIR@/GiBUUTools/src/GiBUUTools-build/Linux/setup.sh
fi
if [ "@USE_NOvARwgt@" != "FALSE" ]; then
export NOVARWGT=@NOVARWGT@
add_to_LD_LIBRARY_PATH @NOVARWGT@/lib
fi
+if [ "@USE_HEPMCNUEVT@" == "TRUE" ]; then
+ add_to_LD_LIBRARY_PATH @HEPMC_LIBDIR@
+ add_to_LD_LIBRARY_PATH @HEPMCNUEVTTOOLSROOT@/lib
+fi
+
export NUISANCE="@CMAKE_SOURCE_DIR@"
diff --git a/src/InputHandler/CMakeLists.txt b/src/InputHandler/CMakeLists.txt
index bf1f2a3..75da29f 100644
--- a/src/InputHandler/CMakeLists.txt
+++ b/src/InputHandler/CMakeLists.txt
@@ -1,92 +1,96 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
set(IMPLFILES
BaseFitEvt.cxx
FitParticle.cxx
FitEvent.cxx
GeneratorUtils.cxx
StdHepEvt.cxx
InputUtils.cxx
NEUTInputHandler.cxx
GENIEInputHandler.cxx
NuWroInputHandler.cxx
GIBUUInputHandler.cxx
NUANCEInputHandler.cxx
InputHandler.cxx
NuanceEvent.cxx
FitEventInputHandler.cxx
SplineInputHandler.cxx
GeneratorInfoBase.h
HepMCTextInputHandler.cxx
InputFactory.cxx
SigmaQ0HistogramInputHandler.cxx
HistogramInputHandler.cxx
)
set(HEADERFILES
BaseFitEvt.h
FitParticle.h
FitEvent.h
GeneratorUtils.h
StdHepEvt.h
InputUtils.h
NEUTInputHandler.h
GENIEInputHandler.h
NuWroInputHandler.h
GIBUUInputHandler.h
NUANCEInputHandler.h
InputHandler.h
NuanceEvent.h
FitEventInputHandler.h
SplineInputHandler.h
GeneratorInfoBase.h
InputTypes.h
HepMCTextInputHandler.h
InputFactory.h
SigmaQ0HistogramInputHandler.h
HistogramInputHandler.h
)
+if(USE_HEPMCNUEVT)
+ LIST(APPEND IMPLFILES HepMCNuEvtInputHandler.cxx)
+endif()
+
set(LIBNAME InputHandler)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_library(${LIBNAME} STATIC ${IMPLFILES})
else(CMAKE_BUILD_TYPE MATCHES RELEASE)
add_library(${LIBNAME} SHARED ${IMPLFILES})
endif()
include_directories(${MINIMUM_INCLUDE_DIRECTORIES})
set_target_properties(${LIBNAME} PROPERTIES VERSION
"${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}")
#set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS})
if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES)
add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES})
endif()
if(HEPMC_USED_EP)
add_dependencies(${LIBNAME} HepMC)
endif()
install(TARGETS ${LIBNAME} DESTINATION lib)
#Can uncomment this to install the headers... but is it really neccessary?
install(FILES ${HEADERFILES} DESTINATION include/InputHandler)
set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE)
diff --git a/src/InputHandler/HepMCNuEvtInputHandler.cxx b/src/InputHandler/HepMCNuEvtInputHandler.cxx
new file mode 100644
index 0000000..e823064
--- /dev/null
+++ b/src/InputHandler/HepMCNuEvtInputHandler.cxx
@@ -0,0 +1,140 @@
+#include "HepMCNuEvtInputHandler.h"
+
+#include "FitEvent.h"
+
+HepMCNuEvtInputHandler::~HepMCNuEvtInputHandler() {
+ if (rdr) {
+ rdr->close();
+ }
+ delete rdr;
+};
+
+void HepMCNuEvtInputHandler::Reset() {
+ if (rdr) {
+ rdr->close();
+ }
+ delete rdr;
+
+ rdr = new HepMC3Nu::ReaderRootTree(fInputFile);
+ fNEvents = rdr->get_entries();
+ fEntriesUsed = 0;
+
+ HepMC3Nu::genruninfo::GRIHelper grih(rdr->run_info());
+
+ fEventHist = new TH1D("eventhist", "eventhist", 1, 0.4, 1.4);
+ fEventHist->SetBinContent(1, grih.GetFluxAverageTotalCrossSection() * 1E38);
+ fFluxHist = new TH1D("fluxhist", "fluxhist", 1, 0.4, 1.4);
+ fFluxHist->SetBinContent(1, 1);
+}
+
+HepMCNuEvtInputHandler::HepMCNuEvtInputHandler(std::string const &handle,
+ std::string const &rawinputs)
+ : rdr(0) {
+ fEventHist = 0;
+ fFluxHist = 0;
+ NUIS_LOG(SAM, "Creating HepMCNuEvtInputHandler : " << handle);
+
+ // Run a joint input handling
+ fName = handle;
+ // Get initial flags
+ fMaxEvents = FitPar::Config().GetParI("MAXEVENTS");
+ fEventType = kHEPMC;
+
+ std::vector inputs = InputUtils::ParseInputFileList(rawinputs);
+ if (inputs.size() != 1) {
+ NUIS_ABORT(
+ "HEPMCNUEVT Input handler can only handler a single input at a time.");
+ }
+ fInputFile = inputs.front();
+
+ Reset();
+
+ fNUISANCEEvent = new FitEvent();
+ fNUISANCEEvent->HardReset();
+ fNUISANCEEvent->SetType(fEventType);
+ fBaseEvent = static_cast(fNUISANCEEvent);
+};
+
+FitEvent *HepMCNuEvtInputHandler::GetNuisanceEvent(const UInt_t entry) {
+
+ // Catch too large entries
+ if (entry >= (UInt_t)fNEvents) {
+ return NULL;
+ }
+
+ if (entry < fEntriesUsed) {
+ Reset();
+ rdr->skip(entry - 1);
+ } else if (entry > fEntriesUsed) {
+ rdr->skip(entry - fEntriesUsed);
+ }
+
+ if (rdr->failed()) {
+ return NULL;
+ }
+
+ HepMC3::GenEvent evt;
+
+ rdr->read_event(evt);
+
+ fNUISANCEEvent->ResetEvent();
+
+ auto LabFrameVertex = HepMC3Nu::GetLabFrameVertex(evt);
+
+ fNUISANCEEvent->Mode = 1; // fNeutVect->Mode;
+ fNUISANCEEvent->fEventNo = evt.event_number();
+
+ UInt_t npart = LabFrameVertex->particles_out().size();
+ UInt_t kmax = fNUISANCEEvent->kMaxParticles;
+ if (npart > kmax) {
+ NUIS_ERR(WRN, "NEUT has too many particles. Expanding stack.");
+ fNUISANCEEvent->ExpandParticleStack(npart);
+ }
+
+ for (auto pin : LabFrameVertex->particles_in()) {
+ int curpart = fNUISANCEEvent->fNParticles;
+ // State
+ fNUISANCEEvent->fParticleState[curpart] = kInitialState;
+
+ fNUISANCEEvent->fPrimaryVertex[curpart] = true;
+
+ // Mom
+ fNUISANCEEvent->fParticleMom[curpart][0] = pin->momentum().x();
+ fNUISANCEEvent->fParticleMom[curpart][1] = pin->momentum().y();
+ fNUISANCEEvent->fParticleMom[curpart][2] = pin->momentum().z();
+ fNUISANCEEvent->fParticleMom[curpart][3] = pin->momentum().e();
+
+ // PDG
+ fNUISANCEEvent->fParticlePDG[curpart] = pin->pid();
+ fNUISANCEEvent->fNParticles++;
+ }
+ for (auto pout : LabFrameVertex->particles_out()) {
+ int curpart = fNUISANCEEvent->fNParticles;
+ // State
+ fNUISANCEEvent->fParticleState[curpart] = kFinalState;
+
+ fNUISANCEEvent->fPrimaryVertex[curpart] = false;
+
+ // Mom
+ fNUISANCEEvent->fParticleMom[curpart][0] = pout->momentum().x();
+ fNUISANCEEvent->fParticleMom[curpart][1] = pout->momentum().y();
+ fNUISANCEEvent->fParticleMom[curpart][2] = pout->momentum().z();
+ fNUISANCEEvent->fParticleMom[curpart][3] = pout->momentum().e();
+
+ // PDG
+ fNUISANCEEvent->fParticlePDG[curpart] = pout->pid();
+ fNUISANCEEvent->fNParticles++;
+ }
+
+ // Add up particle count
+ fNUISANCEEvent->OrderStack();
+
+ FitParticle *ISAnyLepton = fNUISANCEEvent->GetHMISAnyLeptons();
+ if (ISAnyLepton) {
+ fNUISANCEEvent->probe_E = ISAnyLepton->E();
+ fNUISANCEEvent->probe_pdg = ISAnyLepton->PDG();
+ }
+
+ // Return event pointer
+ return fNUISANCEEvent;
+}
diff --git a/src/InputHandler/HepMCNuEvtInputHandler.h b/src/InputHandler/HepMCNuEvtInputHandler.h
new file mode 100644
index 0000000..b062546
--- /dev/null
+++ b/src/InputHandler/HepMCNuEvtInputHandler.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "HepMCNuEvtTools/ReaderTools"
+
+#include "InputHandler.h"
+#include "PlotUtils.h"
+#include "TargetUtils.h"
+
+class HepMCNuEvtInputHandler : public InputHandlerBase {
+public:
+ HepMCNuEvtInputHandler(std::string const &handle,
+ std::string const &rawinputs);
+ ~HepMCNuEvtInputHandler();
+
+ void HepMCNuEvtInputHandler::Reset();
+
+ FitEvent *GetNuisanceEvent(const UInt_t entry);
+
+ UInt_t fEntriesUsed;
+ std::string fInputFile;
+ HepMC3Nu::ReaderRootTree *rdr;
+};
diff --git a/src/InputHandler/HepMCTextInputHandler.cxx b/src/InputHandler/HepMCTextInputHandler.cxx
index b5cf5db..ad05a14 100644
--- a/src/InputHandler/HepMCTextInputHandler.cxx
+++ b/src/InputHandler/HepMCTextInputHandler.cxx
@@ -1,171 +1,171 @@
#ifdef __HEPMC_ENABLED__
#include "HepMCTextInputHandler.h"
HepMCTextInputHandler::~HepMCTextInputHandler(){
-
+
};
HepMCTextInputHandler::HepMCTextInputHandler(std::string const& handle, std::string const& rawinputs) {
NUIS_LOG(SAM, "Creating HepMCTextInputHandler : " << handle );
// Run a joint input handling
fName = handle;
jointinput = false;
jointindexswitch = 0;
// Get initial flags
fMaxEvents = FitPar::Config().GetParI("MAXEVENTS");
// Form list of all inputs, remove brackets if required.
std::vector inputs = GeneralUtils::ParseToStr(rawinputs, ",");
if (inputs.front()[0] == '(') {
inputs.front() = inputs.front().substr(1);
}
if (inputs.back()[inputs.back().size() - 1] == ')') {
inputs.back() = inputs.back().substr(0, inputs.back().size() - 1);
}
for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) {
if (LOG_LEVEL(SAM)) {
std::cout << "\t\t|-> Input File " << inp_it
<< " : " << inputs[inp_it] << std::endl;
}
}
fEventType = kHEPMC;
fASCIIStream = std::ifstream(inputs[0].c_str());
fHepMCEvent = HepMC::GenEvent();
// Loop through events and get N
fNEvents = 0;
while (fASCIIStream){
fHepMCEvent.read(fASCIIStream);
fNEvents++;
}
fASCIIStream.seekg(0);
fEventHist = new TH1D("eventhist","eventhist",10,0.0,1.0);
fFluxHist = new TH1D("eventhist","eventhist",10,0.0,1.0);
fNUISANCEEvent = new FitEvent(kHEPMC);
fNUISANCEEvent->HardReset();
fBaseEvent = static_cast(fNUISANCEEvent);
};
FitEvent* HepMCTextInputHandler::GetNuisanceEvent(const UInt_t entry) {
// Catch too large entries
if (entry >= (UInt_t)fNEvents){
fASCIIStream.seekg(0);
return NULL;
}
// If no event get the first one
if (!fHepMCEvent.is_valid()){
fHepMCEvent.read(fASCIIStream);
}
// Read Entry from TTree to fill NEUT Vect in BaseFitEvt;
if (fHepMCEvent.event_number() != entry){
// If have to read backwords skip to start of ifstream
if (fHepMCEvent.event_number() > entry){
fASCIIStream.seekg(0);
fHepMCEvent.read(fASCIIStream);
}
-
+
// Loop to event before if reading forwards
while (fHepMCEvent.event_number() < entry - 1 and fASCIIStream){
fHepMCEvent.read(fASCIIStream);
}
-
+
fHepMCEvent.read(fASCIIStream);
}
// Setup Input scaling for joint inputs
if (jointinput) {
fNUISANCEEvent->InputWeight = GetInputWeight(entry);
} else {
fNUISANCEEvent->InputWeight = 1.0;
}
-
+
// Run NUISANCE Vector Filler
CalcNUISANCEKinematics();
-
+
// Return event pointer
return fNUISANCEEvent;
}
int HepMCTextInputHandler::ConvertHepMCStatus() {
// Status for HepMC convertor
return 0;
}
void HepMCTextInputHandler::CalcNUISANCEKinematics() {
// Reset all variables
fNUISANCEEvent->ResetEvent();
// Read all particles from fHepMCEvent
std::vector allstateparticles;
for ( HepMC::GenEvent::particle_iterator p = fHepMCEvent.particles_begin();
p != fHepMCEvent.particles_end(); ++p ){
allstateparticles.push_back(*p);
int pdg = (*p)->pdg_id();
int status = (*p)->status();
// FourVector vect = (*p)->momentum();
int state = ConvertHepMCStatus(status);
int curpart = fNUISANCEEvent->fNParticles;
fNUISANCEEvent->fParticleState[curpart] = state;
- // Mom
+ // Mom
// fNUISANCEEvent->fParticleMom[curpart][0] = vect.px();
// fNUISANCEEvent->fParticleMom[curpart][1] = vect.py();
// fNUISANCEEvent->fParticleMom[curpart][2] = vect.pz();
// fNUISANCEEvent->fParticleMom[curpart][3] = vect.e();
- // PDG
+ // PDG
fNUISANCEEvent->fParticlePDG[curpart] = pdg;
- // Add up particle count
+ // Add up particle count
fNUISANCEEvent->fNParticles++;
}
-
+
// Run Initial, FSI, Final, Other ordering.
fNUISANCEEvent-> OrderStack();
return;
}
double HepMCTextInputHandler::GetInputWeight(const UInt_t entry) {
// Find Switch Scale
while ( entry < (UInt_t)jointindexlow[jointindexswitch] ||
entry >= (UInt_t)jointindexhigh[jointindexswitch] ) {
jointindexswitch++;
// Loop Around
if (jointindexswitch == jointindexlow.size()) {
jointindexswitch = 0;
}
}
return jointindexscale[jointindexswitch];
};
BaseFitEvt* HepMCTextInputHandler::GetBaseEvent(const UInt_t entry) {
// Read entry from TTree to fill NEUT Vect in BaseFitEvt;
if (entry >= (UInt_t)fNEvents) return NULL;
return (BaseFitEvent*)GetNuisanceEvent(entry);
}
#endif
diff --git a/src/InputHandler/InputUtils.cxx b/src/InputHandler/InputUtils.cxx
index ebbe6c7..961b81b 100644
--- a/src/InputHandler/InputUtils.cxx
+++ b/src/InputHandler/InputUtils.cxx
@@ -1,171 +1,172 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE 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 3 of the License, or
* (at your option) any later version.
*
* NUISANCE 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 NUISANCE. If not, see .
*******************************************************************************/
#include "GeneralUtils.h"
#include "InputHandler.h"
#include "InputUtils.h"
namespace InputUtils {
std::vector ParseInputFileList(std::string const &inpFile) {
std::vector inputs = GeneralUtils::ParseToStr(inpFile, ",");
if (inputs.front()[0] == '(') {
inputs.front() = inputs.front().substr(1);
}
if (inputs.back()[inputs.back().size() - 1] == ')') {
inputs.back() = inputs.back().substr(0, inputs.back().size() - 1);
}
return inputs;
}
InputType ParseInputType(std::string const &inp) {
// The hard-coded list of supported input generators
const static std::string filetypes[] = {
"NEUT", "NUWRO", "GENIE", "GiBUU", "NUANCE", "EVSPLN",
- "EMPTY", "FEVENT", "JOINT", "SIGMAQ0HIST", "HISTO"};
+ "EMPTY", "FEVENT", "JOINT", "SIGMAQ0HIST", "HISTO", "HEPMCNUEVT"};
size_t nInputTypes = GeneralUtils::GetArraySize(filetypes);
for (size_t i = 0; i < nInputTypes; i++) {
if (inp == filetypes[i]) {
return InputType(i);
}
}
return kInvalid_Input;
}
bool IsJointInput(std::string const &inputs) {
bool isJoint = (inputs[0] == '(');
if (isJoint && (inputs[inputs.length() - 1] != ')')) {
- NUIS_ABORT("Inputs specifier: \""
- << inputs
- << "\" looks like a composite input specifier -- "
- "(filea.root,fileb.root), however, it did not end in a \')\', "
- "it ended in a \'"
- << inputs[inputs.length() - 1] << "\'");
+ NUIS_ABORT(
+ "Inputs specifier: \""
+ << inputs
+ << "\" looks like a composite input specifier -- "
+ "(filea.root,fileb.root), however, it did not end in a \')\', "
+ "it ended in a \'"
+ << inputs[inputs.length() - 1] << "\'");
}
return isJoint;
}
std::string ExpandInputDirectories(std::string const &inputs) {
// Parse the "environement" flags in the fitter config
// Can specify NEUT_DIR = "" and others in parameters/fitter.config.dat
const static std::string filedir[] = {"NEUT_DIR", "NUWRO_DIR",
"GENIE_DIR", "NUANCE_DIR",
"EVSPLN_DIR", "GIBUU_DIR"};
size_t nfiledir = GeneralUtils::GetArraySize(filedir);
std::string expandedInputs = inputs;
for (size_t i = 0; i < nfiledir; i++) {
std::string tempdir = "@" + filedir[i];
bool didRpl;
do {
size_t torpl = expandedInputs.find(tempdir);
if (torpl != std::string::npos) {
std::string event_folder = FitPar::Config().GetParS(filedir[i]);
expandedInputs.replace(torpl, tempdir.size(), event_folder);
didRpl = true;
} else {
didRpl = false;
}
} while (didRpl);
}
bool didRpl;
do {
size_t torpl = expandedInputs.find("//");
if (torpl != std::string::npos) {
expandedInputs.replace(torpl, 2, "/");
didRpl = true;
} else {
didRpl = false;
}
} while (didRpl);
return expandedInputs;
}
InputType GuessInputTypeFromFile(TFile *inpF) {
const std::string NEUT_TreeName = "neuttree";
const std::string NuWro_TreeName = "treeout";
const std::string GENIE_TreeName = "gtree";
const std::string GiBUU_TreeName = "giRooTracker";
if (!inpF) {
return kInvalid_Input;
}
TTree *NEUT_Input = dynamic_cast(inpF->Get(NEUT_TreeName.c_str()));
if (NEUT_Input) {
return kNEUT_Input;
}
TTree *NUWRO_Input = dynamic_cast(inpF->Get(NuWro_TreeName.c_str()));
if (NUWRO_Input) {
return kNUWRO_Input;
}
TTree *GENIE_Input = dynamic_cast(inpF->Get(GENIE_TreeName.c_str()));
if (GENIE_Input) {
return kGENIE_Input;
}
TTree *GiBUU_Input = dynamic_cast(inpF->Get(GiBUU_TreeName.c_str()));
if (GiBUU_Input) {
return kGiBUU_Input;
}
return kInvalid_Input;
}
std::string PrependGuessedInputTypeToName(std::string const &inpFName) {
// If it already has a name.
if (inpFName.find(":") != std::string::npos) {
return inpFName;
}
TFile *inpF = TFile::Open(inpFName.c_str(), "READ");
if (!inpF || !inpF->IsOpen()) {
NUIS_ABORT("Couldn't open \"" << inpFName << "\" for reading.");
}
InputType iType = GuessInputTypeFromFile(inpF);
if (iType == kInvalid_Input) {
NUIS_ABORT("Couldn't determine input type from file: " << inpFName << ".");
}
inpF->Close();
delete inpF;
switch (iType) {
case kNEUT_Input: {
return "NEUT:" + inpFName;
}
case kNUWRO_Input: {
return "NUWRO:" + inpFName;
}
case kGENIE_Input: {
return "GENIE:" + inpFName;
}
case kGiBUU_Input: {
return "GiBUU:" + inpFName;
}
default: {
NUIS_ABORT("Input type from file: " << inpFName << " was invalid.");
throw;
}
}
}
} // namespace InputUtils
diff --git a/src/Reweight/CMakeLists.txt b/src/Reweight/CMakeLists.txt
index 2684e27..17624bd 100644
--- a/src/Reweight/CMakeLists.txt
+++ b/src/Reweight/CMakeLists.txt
@@ -1,92 +1,96 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE 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 3 of the License, or
# (at your option) any later version.
#
# NUISANCE 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 NUISANCE. If not, see .
################################################################################
set(IMPLFILES
GlobalDialList.cxx
FitWeight.cxx
WeightEngineBase.cxx
NEUTWeightEngine.cxx
NuWroWeightEngine.cxx
GENIEWeightEngine.cxx
WeightUtils.cxx
SampleNormEngine.cxx
LikelihoodWeightEngine.cxx
SplineWeightEngine.cxx
NUISANCESyst.cxx
T2KWeightEngine.cxx
NUISANCEWeightEngine.cxx
NUISANCEWeightCalcs.cxx
NIWGWeightEngine.cxx
OscWeightEngine.cxx
MINERvAWeightCalcs.cxx
weightRPA.h
)
if(USE_NOvARwgt)
LIST(APPEND IMPLFILES NOvARwgtEngine.cxx)
endif()
+if(USE_DUNERWT)
+ LIST(APPEND IMPLFILES nusystematicsWeightEngine.cxx)
+endif()
+
set(HEADERFILES
GlobalDialList.h
FitWeight.h
WeightEngineBase.h
NEUTWeightEngine.h
NuWroWeightEngine.h
GENIEWeightEngine.h
WeightUtils.h
SampleNormEngine.h
LikelihoodWeightEngine.h
SplineWeightEngine.h
NUISANCESyst.h
T2KWeightEngine.h
NUISANCEWeightEngine.h
NUISANCEWeightCalcs.h
NIWGWeightEngine.h
OscWeightEngine.h
MINERvAWeightCalcs.h
weightRPA.h
BeRPA.h
)
if(USE_NOvARwgt)
LIST(APPEND HEADERFILES NOvARwgtEngine.h)
endif()
set(LIBNAME Reweight)
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
add_library(${LIBNAME} STATIC ${IMPLFILES})
else(CMAKE_BUILD_TYPE MATCHES RELEASE)
add_library(${LIBNAME} SHARED ${IMPLFILES})
endif()
include_directories(${MINIMUM_INCLUDE_DIRECTORIES})
set_target_properties(${LIBNAME} PROPERTIES VERSION
"${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}")
#set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS})
if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES)
add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES})
endif()
install(TARGETS ${LIBNAME} DESTINATION lib)
#Can uncomment this to install the headers... but is it really neccessary?
install(FILES ${HEADERFILES} DESTINATION include/Reweight)
set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE)
diff --git a/src/Reweight/NOvARwgtEngine.cxx b/src/Reweight/NOvARwgtEngine.cxx
index f40eafb..1277db9 100644
--- a/src/Reweight/NOvARwgtEngine.cxx
+++ b/src/Reweight/NOvARwgtEngine.cxx
@@ -1,352 +1,232 @@
#include "NOvARwgtEngine.h"
#include "NOvARwgt/interfaces/GenieInterface.h"
-#include "NOvARwgt/rwgt/genie/QE/MAQEWgts.h"
-#include "NOvARwgt/rwgt/genie/QE/RPAWeights.h"
-
-#include "NOvARwgt/rwgt/genie/MEC/EmpiricalMECOtherTunes.h"
-#include "NOvARwgt/rwgt/genie/MEC/EmpiricalMECTune2017.h"
-#include "NOvARwgt/rwgt/genie/MEC/EmpiricalMECTune2018.h"
-#include "NOvARwgt/rwgt/genie/MEC/EmpiricalMECTuneSA.h"
-
-#include "NOvARwgt/rwgt/genie/DIS/HighWDISWeight.h"
-#include "NOvARwgt/rwgt/genie/DIS/Nonres1piWeights.h"
-
#include "NOvARwgt/rwgt/tunes/Tunes2017.h"
#include "NOvARwgt/rwgt/tunes/Tunes2018.h"
#include "NOvARwgt/rwgt/tunes/Tunes2019.h"
#include "NOvARwgt/rwgt/tunes/TunesSA.h"
#include "NOvARwgt/rwgt/EventRecord.h"
-#include "NOvARwgt/rwgt/IWeightGenerator.h"
#include "NOvARwgt/rwgt/Tune.h"
+#include "NOvARwgt/rwgt/ISystKnob.h"
-static size_t const kRPAWeightCCQESA = 0;
-static size_t const kRPAWeightCCQE_2017 = 1;
-static size_t const kRPAWeightQ2_2017 = 2;
-static size_t const kMAQEWeight_2018 = 3;
-static size_t const kTufts2p2hWgtSA = 4;
-static size_t const kEmpiricalMEC_to_Valencia_Wgt = 5;
-static size_t const kEmpiricalMECWgt2018 = 6;
-static size_t const kMECEnuShapeWgt = 7;
-static size_t const kMECInitStateNPFracWgt = 8;
-static size_t const kEmpiricalMECWgt2017 = 9;
-static size_t const kEmpiricalMEC_to_GENIEQE_Wgt = 10;
-static size_t const kEmpiricalMEC_to_GENIERES_Wgt = 11;
-static size_t const kEmpiricalMECWgt2018RPAFix = 12;
-static size_t const kMEC2018_QElike_Wgt = 13;
-static size_t const kMEC2018_RESlike_Wgt = 14;
-static size_t const kMEC2018RPAFix_QElike_Wgt = 15;
-static size_t const kMEC2018RPAFix_RESlike_Wgt = 16;
-static size_t const kNonres1PiWgt = 17;
-static size_t const kHighWDISWgt_2018 = 18;
-static size_t const kRESRPAWeightQ2_2017 = 19;
-static size_t const kTuneSeparator = 100;
-static size_t const kTune2017 = kTuneSeparator + 1;
-static size_t const kTune2018 = kTuneSeparator + 2;
-static size_t const kTune2019 = kTuneSeparator + 3;
-static size_t const kTuneSA = kTuneSeparator + 4;
-static size_t const kNoSuchWeightEngine = std::numeric_limits::max();
+static size_t const kCVTune2017 = 100;
+static size_t const kCVTune2018 = 200;
+static size_t const kCVTune2019 = 300;
+static size_t const kCVTuneSA = 400;
+static size_t const kNoSuchKnob = std::numeric_limits::max();
size_t NOvARwgtEngine::GetWeightGeneratorIndex(std::string const &strname) {
+ int upos = strname.find_first_of("_");
- if (strname == "RPAWeightCCQESA") {
- return kRPAWeightCCQESA;
- } else if (strname == "RPAWeightCCQE_2017") {
- return kRPAWeightCCQE_2017;
- } else if (strname == "RPAWeightQ2_2017") {
- return kRPAWeightQ2_2017;
- } else if (strname == "RESRPAWeightQ2_2017") {
- return kRESRPAWeightQ2_2017;
- } else if (strname == "MAQEWeight_2018") {
- return kMAQEWeight_2018;
- } else if (strname == "Tufts2p2hWgtSA") {
- return kTufts2p2hWgtSA;
- } else if (strname == "EmpiricalMEC_to_Valencia_Wgt") {
- return kEmpiricalMEC_to_Valencia_Wgt;
- } else if (strname == "EmpiricalMECWgt2018") {
- return kEmpiricalMECWgt2018;
- } else if (strname == "MECEnuShapeWgt") {
- return kMECEnuShapeWgt;
- } else if (strname == "MECInitStateNPFracWgt") {
- return kMECInitStateNPFracWgt;
- } else if (strname == "EmpiricalMECWgt2017") {
- return kEmpiricalMECWgt2017;
- } else if (strname == "EmpiricalMEC_to_GENIEQE_Wgt") {
- return kEmpiricalMEC_to_GENIEQE_Wgt;
- } else if (strname == "EmpiricalMEC_to_GENIERES_Wgt") {
- return kEmpiricalMEC_to_GENIERES_Wgt;
- } else if (strname == "EmpiricalMECWgt2018RPAFix") {
- return kEmpiricalMECWgt2018RPAFix;
- } else if (strname == "MEC2018_QElike_Wgt") {
- return kMEC2018_QElike_Wgt;
- } else if (strname == "MEC2018_RESlike_Wgt") {
- return kMEC2018_RESlike_Wgt;
- } else if (strname == "MEC2018RPAFix_QElike_Wgt") {
- return kMEC2018RPAFix_QElike_Wgt;
- } else if (strname == "MEC2018RPAFix_RESlike_Wgt") {
- return kMEC2018RPAFix_RESlike_Wgt;
- } else if (strname == "Nonres1PiWgt") {
- return kNonres1PiWgt;
- } else if (strname == "HighWDISWgt_2018") {
- return kHighWDISWgt_2018;
- } else if (strname == "Tune2017") {
- return kTune2017;
- } else if (strname == "Tune2018") {
- return kTune2018;
- } else if (strname == "Tune2019") {
- return kTune2019;
- } else if (strname == "TuneSA") {
- return kTuneSA;
- }
- return kNoSuchWeightEngine;
-}
-
-novarwgt::IWeightGenerator *IWeightGeneratorFactory(size_t e) {
- switch (e) {
- case kRPAWeightCCQESA: {
- return new novarwgt::RPAWeightCCQESA();
- }
- case kRPAWeightCCQE_2017: {
- return new novarwgt::RPAWeightCCQE_2017("CV");
- }
- case kRPAWeightQ2_2017: {
- return new novarwgt::RPAWeightQ2_2017();
- }
- case kRESRPAWeightQ2_2017: {
- return new novarwgt::RPAWeightQ2_2017(novarwgt::kRxnCC, novarwgt::kScResonant);
- }
- case kMAQEWeight_2018: {
- return new novarwgt::MAQEWeight_2018();
- }
- case kTufts2p2hWgtSA: {
- return new novarwgt::Tufts2p2hWgtSA();
- }
- case kEmpiricalMEC_to_Valencia_Wgt: {
- return new novarwgt::EmpiricalMEC_to_Valencia_Wgt();
- }
- case kEmpiricalMECWgt2018: {
- return new novarwgt::EmpiricalMECWgt2018();
- }
- case kMECEnuShapeWgt: {
- return new novarwgt::MECEnuShapeWgt();
- }
- case kMECInitStateNPFracWgt: {
- return new novarwgt::MECInitStateNPFracWgt();
- }
- case kEmpiricalMECWgt2017: {
- return new novarwgt::EmpiricalMECWgt2017();
- }
- case kEmpiricalMEC_to_GENIEQE_Wgt: {
- return new novarwgt::EmpiricalMEC_to_GENIEQE_Wgt();
- }
- case kEmpiricalMEC_to_GENIERES_Wgt: {
- return new novarwgt::EmpiricalMEC_to_GENIERES_Wgt();
- }
- case kEmpiricalMECWgt2018RPAFix: {
- return new novarwgt::EmpiricalMECWgt2018RPAFix();
- }
- case kMEC2018_QElike_Wgt: {
- return new novarwgt::MEC2018_QElike_Wgt();
- }
- case kMEC2018_RESlike_Wgt: {
- return new novarwgt::MEC2018_RESlike_Wgt();
- }
- case kMEC2018RPAFix_QElike_Wgt: {
- return new novarwgt::MEC2018RPAFix_QElike_Wgt();
- }
- case kMEC2018RPAFix_RESlike_Wgt: {
- return new novarwgt::MEC2018RPAFix_RESlike_Wgt();
- }
- case kNonres1PiWgt: {
- return new novarwgt::Nonres1PiWgt();
- }
- case kHighWDISWgt_2018: {
- return new novarwgt::HighWDISWgt_2018();
- }
- default: { return NULL; }
+ if (strname.find("CVTune2017") == 0) {
+ if (upos == std::string::npos) {
+ return kCVTune2017;
+ }
+ std::string knobname = strname.substr(upos + 1);
+ if (novarwgt::kCVTune2017.SystKnobs().contains(knobname)) {
+ auto loc = std::find(fKnobs.begin(), fKnobs.end(),
+ novarwgt::kCVTune2017.SystKnobs()[knobname]);
+ if (loc == fKnobs.end()) {
+ size_t rtn = kCVTune2017 + 1 + fKnobs.size();
+ fKnobs.push_back(novarwgt::kCVTune2017.SystKnobs()[knobname]);
+ return rtn;
+ } else {
+ return kCVTune2017 + 1 + std::distance(fKnobs.begin(), loc);
+ }
+ }
+ } else if (strname.find("CVTune2018") == 0) {
+ if (upos == std::string::npos) {
+ return kCVTune2018;
+ }
+ std::string knobname = strname.substr(upos + 1);
+ if (novarwgt::kCVTune2018.SystKnobs().contains(knobname)) {
+ auto loc = std::find(fKnobs.begin(), fKnobs.end(),
+ novarwgt::kCVTune2018.SystKnobs()[knobname]);
+ if (loc == fKnobs.end()) {
+ size_t rtn = kCVTune2018 + 1 + fKnobs.size();
+ fKnobs.push_back(novarwgt::kCVTune2018.SystKnobs()[knobname]);
+ return rtn;
+ } else {
+ return kCVTune2018 + 1 + std::distance(fKnobs.begin(), loc);
+ }
+ }
+ } else if (strname.find("CVTune2019") == 0) {
+ if (upos == std::string::npos) {
+ return kCVTune2019;
+ }
+ std::string knobname = strname.substr(upos + 1);
+ if (novarwgt::kCVTune2019.SystKnobs().contains(knobname)) {
+ auto loc = std::find(fKnobs.begin(), fKnobs.end(),
+ novarwgt::kCVTune2019.SystKnobs()[knobname]);
+ if (loc == fKnobs.end()) {
+ size_t rtn = kCVTune2019 + 1 + fKnobs.size();
+ fKnobs.push_back(novarwgt::kCVTune2019.SystKnobs()[knobname]);
+ return rtn;
+ } else {
+ return kCVTune2019 + 1 + std::distance(fKnobs.begin(), loc);
+ }
+ }
+ } else if (strname.find("CVTuneSA") == 0) {
+ if (upos == std::string::npos) {
+ return kCVTuneSA;
+ }
+ std::string knobname = strname.substr(upos + 1);
+ if (novarwgt::kCVTuneSA.SystKnobs().contains(knobname)) {
+ auto loc = std::find(fKnobs.begin(), fKnobs.end(),
+ novarwgt::kCVTuneSA.SystKnobs()[knobname]);
+ if (loc == fKnobs.end()) {
+ size_t rtn = kCVTuneSA + 1 + fKnobs.size();
+ fKnobs.push_back(novarwgt::kCVTuneSA.SystKnobs()[knobname]);
+ return rtn;
+ } else {
+ return kCVTuneSA + 1 + std::distance(fKnobs.begin(), loc);
+ }
+ }
}
+ return kNoSuchKnob;
}
novarwgt::Tune const *TuneFactory(size_t e) {
switch (e) {
case kTune2017: {
return &novarwgt::kCVTune2017;
}
case kTune2018: {
return &novarwgt::kCVTune2018;
}
case kTune2019: {
return &novarwgt::kCVTune2019;
}
case kTuneSA: {
return &novarwgt::kCVTuneSA;
}
default: { return NULL; }
}
}
void NOvARwgtEngine::IncludeDial(std::string name, double startval) {
size_t we_e = GetWeightGeneratorIndex(name);
- if (we_e == kNoSuchWeightEngine) {
+ if (we_e == kNoSuchKnob) {
NUIS_ABORT("[ERROR]: Invalid NOvARwgt Engine name: " << name);
}
- if (we_e < kTuneSeparator) {
- if (fWeightEngineEnums.find(we_e) != fWeightEngineEnums.end()) {
- NUIS_ABORT("[ERROR]: NOvARwgt Engine name: " << name << " already included.");
- }
- fWeightEngineEnums[we_e] = fWeightEngines.size();
- fWeightEngines.push_back(IWeightGeneratorFactory(we_e));
- fWeightEngineValues.push_back(startval);
- } else {
+ bool IsTune = !(we_e % 100);
+ if (IsTune) {
if (fTuneEnums.find(we_e) != fTuneEnums.end()) {
- NUIS_ABORT("[ERROR]: NOvARwgt Tune name: " << name << " already included.");
+ NUIS_ABORT("[ERROR]: NOvARwgt Tune name: " << name
+ << " already included.");
}
fTuneEnums[we_e] = fTunes.size();
fTunes.push_back(TuneFactory(we_e));
fTuneValues.push_back(startval);
+ } else {
+ // The GetWeightGeneratorIndex caches the Knob so we don't have to.
+ fKnobEnums[we_e] = fKnobValues.size();
+ fKnobValues.push_back(startval);
}
};
void NOvARwgtEngine::SetDialValue(int nuisenum, double val) {
size_t we_indx = (nuisenum % 1000);
- if (we_indx < kTuneSeparator) {
- if (!fWeightEngineEnums.count(we_indx)) {
- NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that engine hasn't been included yet.");
- }
- size_t engine_index = fWeightEngineEnums[we_indx];
+ bool IsTune = !(we_e % 100);
- fWeightEngineValues[engine_index] = val;
- } else {
+ if (IsTune) {
if (!fTuneEnums.count(we_indx)) {
NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that tune hasn't been included yet.");
+ << we_indx << " but that tune hasn't been included yet.");
}
size_t engine_index = fTuneEnums[we_indx];
-
fTuneValues[engine_index] = val;
- }
-}
-
-void NOvARwgtEngine::SetDialValue(std::string name, double val) {
- size_t we_indx = GetWeightGeneratorIndex(name);
- if (we_indx == kNoSuchWeightEngine) {
- NUIS_ABORT("[ERROR]: Invalid NOvARwgt Engine name: " << name);
- }
- if (we_indx < kTuneSeparator) {
- if (!fWeightEngineEnums.count(we_indx)) {
- NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that engine hasn't been included yet.");
- }
- size_t engine_index = fWeightEngineEnums[we_indx];
-
- fWeightEngineValues[engine_index] = val;
} else {
- if (!fTuneEnums.count(we_indx)) {
+ if (!fKnobEnums.count(we_indx)) {
NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that tune hasn't been included yet.");
+ << we_indx << " but that Knob hasn't been included yet.");
}
- size_t engine_index = fTuneEnums[we_indx];
-
- fTuneValues[engine_index] = val;
+ size_t engine_index = fKnobEnums[we_indx];
+ fKnobValues[engine_index] = val;
}
}
+void NOvARwgtEngine::SetDialValue(std::string name, double val) {
+ SetDialValue(GetWeightGeneratorIndex(name), val);
+}
+
bool NOvARwgtEngine::IsDialIncluded(std::string name) {
- size_t we_indx = GetWeightGeneratorIndex(name);
- if (we_indx == kNoSuchWeightEngine) {
- NUIS_ABORT("[ERROR]: Invalid NOvARwgt Engine name: " << name);
- }
- if (we_indx < kTuneSeparator) {
- return fWeightEngineEnums.count(we_indx);
- } else {
- return fTuneEnums.count(we_indx);
- }
+ return IsDialIncluded(GetWeightGeneratorIndex(name));
}
bool NOvARwgtEngine::IsDialIncluded(int nuisenum) {
size_t we_indx = (nuisenum % 1000);
- if (we_indx < kTuneSeparator) {
- return fWeightEngineEnums.count(we_indx);
- } else {
+ bool IsTune = !(we_e % 100);
+
+ if (IsTune) {
return fTuneEnums.count(we_indx);
+ } else {
+ return fKnobEnums.count(we_indx);
}
}
double NOvARwgtEngine::GetDialValue(std::string name) {
- size_t we_indx = GetWeightGeneratorIndex(name);
- if (we_indx == kNoSuchWeightEngine) {
+ return GetDialValueGetWeightGeneratorIndex(name));
+}
+double NOvARwgtEngine::GetDialValue(int nuisenum) {
+ size_t we_indx = (nuisenum % 1000);
+ if (we_indx == kNoSuchKnob) {
NUIS_ABORT("[ERROR]: Invalid NOvARwgt Engine name: " << name);
}
- if (we_indx < kTuneSeparator) {
- if (!fWeightEngineEnums.count(we_indx)) {
- NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that engine hasn't been included yet.");
- }
- return fWeightEngineValues[fWeightEngineEnums[we_indx]];
- } else {
+ bool IsTune = !(we_e % 100);
+
+ if (IsTune) {
if (!fTuneEnums.count(we_indx)) {
NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that tune hasn't been included yet.");
+ << we_indx << " but that tune hasn't been included yet.");
}
return fTuneValues[fTuneEnums[we_indx]];
- }
-}
-double NOvARwgtEngine::GetDialValue(int nuisenum) {
- size_t we_indx = (nuisenum % 1000);
- if (!fWeightEngineEnums.count(we_indx)) {
- NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
- << we_indx << " but that engine hasn't been included yet.");
- }
- if (we_indx < kTuneSeparator) {
- return fWeightEngineValues[fWeightEngineEnums[we_indx]];
} else {
- return fTuneValues[fTuneEnums[we_indx]];
+
+ if (!fKnobEnums.count(we_indx)) {
+ NUIS_ABORT("[ERROR]: SetDialValue for NOvARwgt dial: "
+ << we_indx << " but that engine hasn't been included yet.");
+ }
+ return fKnobValues[fKnobEnums[we_indx]];
}
}
double NOvARwgtEngine::CalcWeight(BaseFitEvt *evt) {
double rw_weight = 1.0;
// Make nom weight
if (!evt) {
NUIS_ABORT("evt not found : " << evt);
}
// Skip Non GENIE
if (evt->fType != kGENIE)
return 1.0;
if (!(evt->genie_event)) {
NUIS_ABORT("evt->genie_event not found!" << evt->genie_event);
}
if (!(evt->genie_event->event)) {
NUIS_ABORT("evt->genie_event->event GHepRecord not found!"
- << (evt->genie_event->event));
+ << (evt->genie_event->event));
}
novarwgt::EventRecord rcd =
novarwgt::ConvertGenieEvent(evt->genie_event->event);
- static novarwgt::InputVals const dummyparams;
-
- for (size_t w_it = 0; w_it < fWeightEngines.size(); ++w_it) {
- if (fWeightEngineValues[w_it] ==
- 0) { // if a dial is set to 0, don't include its weight
- continue;
- }
- rw_weight *= fWeightEngines[w_it]->GetWeight(rcd, dummyparams);
+ for (size_t w_it = 0; w_it < fKnobs.size(); ++w_it) {
+ rw_weight *= fKnobs[w_it]->CalcWeight(fKnobValues[w_it], rcd);
}
for (size_t w_it = 0; w_it < fTunes.size(); ++w_it) {
if (fTuneValues[w_it] ==
0) { // if a dial is set to 0, don't include its weight
continue;
}
rw_weight *= fTunes[w_it]->EventWeight(rcd);
}
return rw_weight;
}
diff --git a/src/Reweight/NOvARwgtEngine.h b/src/Reweight/NOvARwgtEngine.h
index 2f33e17..33d96d1 100644
--- a/src/Reweight/NOvARwgtEngine.h
+++ b/src/Reweight/NOvARwgtEngine.h
@@ -1,41 +1,41 @@
#pragma once
#include "WeightEngineBase.h"
namespace novarwgt {
-class IWeightGenerator;
+class ISystKnob;
class Tune;
}
class NOvARwgtEngine : public WeightEngineBase {
public:
NOvARwgtEngine(){};
virtual ~NOvARwgtEngine(){};
static size_t GetWeightGeneratorIndex(std::string const &);
// Functions requiring Override
void IncludeDial(std::string name, double startval);
void SetDialValue(int nuisenum, double val);
void SetDialValue(std::string name, double val);
bool IsDialIncluded(std::string name);
bool IsDialIncluded(int nuisenum);
double GetDialValue(std::string name);
double GetDialValue(int nuisenum);
void Reconfigure(bool silent){};
double CalcWeight(BaseFitEvt *evt);
bool NeedsEventReWeight() { return true; }
- std::map fWeightEngineEnums;
- std::vector fWeightEngines;
- std::vector fWeightEngineValues;
-
std::map fTuneEnums;
std::vector fTunes;
std::vector fTuneValues;
+
+ std::map fKnobEnums;
+ std::vector fKnobs;
+ std::vector fKnobValues;
};
diff --git a/src/Reweight/nusystWeightEngine.cxx b/src/Reweight/nusystWeightEngine.cxx
new file mode 100644
index 0000000..d3c4b3c
--- /dev/null
+++ b/src/Reweight/nusystWeightEngine.cxx
@@ -0,0 +1,116 @@
+// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+/*******************************************************************************
+ * This file is part of NUISANCE.
+ *
+ * NUISANCE 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * NUISANCE 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 NUISANCE. If not, see .
+ *******************************************************************************/
+
+#include "nusystWeightEngine.h"
+
+#include
+#include
+
+nusystWeightEngine::nusystWeightEngine() { Config(); }
+
+void nusystWeightEngine::Config() {
+ std::vector DuneRwtParam = Config::QueryKeys("DUNERwt");
+
+ if (DuneRwtParam.size() < 1) {
+ ERROR(WRN, "Instantiaged nusystWeightEngine but without specifying a "
+ "DUNERwt element that leads the way to the configuration.");
+ sleep(10);
+ return;
+ }
+
+ std::string fhicl_name = DuneRwtParam.front().GetS("ConfigFHiCL");
+
+ DUNErwt.LoadConfiguration(fhicl_name);
+}
+
+int nusystWeightEngine::ConvDial(std::string name) {
+ if (!DUNErwt.HaveHeader(name)) {
+ THROW("nusystWeightEngine passed dial: "
+ << name << " that it does not understand.");
+ }
+ return DUNErwt.GetHeaderId(name);
+}
+
+void nusystWeightEngine::IncludeDial(std::string name, double startval) {
+ EnabledParams.push_back({systtools::paramId_t(ConvDial(name)), startval});
+}
+
+void nusystWeightEngine::SetDialValue(int nuisenum, double val) {
+
+ systtools::paramId_t DuneRwtEnum = (nuisenum % 1000);
+ systtools::ParamValue &pval =
+ GetParamElementFromContainer(EnabledParams, DuneRwtEnum);
+ fHasChanged = (pval.val - val) > std::numeric_limits::epsilon();
+ pval.val = val;
+}
+void nusystWeightEngine::SetDialValue(std::string name, double val) {
+ if (!IsDialIncluded(name)) {
+ THROW("nusystWeightEngine passed dial: " << name
+ << " that is not enabled.");
+ }
+
+ systtools::ParamValue &pval =
+ GetParamElementFromContainer(EnabledParams, ConvDial(name));
+ fHasChanged = (pval.val - val) > std::numeric_limits::epsilon();
+ pval.val = val;
+}
+
+bool nusystWeightEngine::IsDialIncluded(std::string name) {
+ return IsDialIncluded(ConvDial(name));
+}
+bool nusystWeightEngine::IsDialIncluded(int nuisenum) {
+ systtools::paramId_t DuneRwtEnum = (nuisenum % 1000);
+ return systtools::ContainterHasParam(EnabledParams, DuneRwtEnum);
+}
+
+double nusystWeightEngine::GetDialValue(std::string name) {
+ if (!IsDialIncluded(name)) {
+ THROW("nusystWeightEngine passed dial: " << name
+ << " that is not enabled.");
+ }
+ systtools::ParamValue &pval =
+ GetParamElementFromContainer(EnabledParams, ConvDial(name));
+ return pval.val;
+}
+double nusystWeightEngine::GetDialValue(int nuisenum) {
+ if (!IsDialIncluded(nuisenum)) {
+ THROW("nusystWeightEngine passed dial: " << nuisenum
+ << " that is not enabled.");
+ }
+ systtools::paramId_t DuneRwtEnum = (nuisenum % 1000);
+ systtools::ParamValue &pval =
+ GetParamElementFromContainer(EnabledParams, DuneRwtEnum);
+ return pval.val;
+}
+
+void nusystWeightEngine::Reconfigure(bool silent) { fHasChanged = false; };
+
+bool nusystWeightEngine::NeedsEventReWeight() {
+ if (fHasChanged) {
+ return true;
+ }
+ return false;
+}
+
+double nusystWeightEngine::CalcWeight(BaseFitEvt *evt) {
+ return DUNErwt.GetEventWeightResponse(*evt->genie_record,
+}
+
+void nusystWeightEngine::Print() {
+ std::cout << "nusystWeightEngine: " << std::endl;
+}
diff --git a/src/Reweight/nusystWeightEngine.h b/src/Reweight/nusystWeightEngine.h
new file mode 100644
index 0000000..ef20548
--- /dev/null
+++ b/src/Reweight/nusystWeightEngine.h
@@ -0,0 +1,64 @@
+#ifndef nusystWeightEngine_SEEN
+#define nusystWeightEngine_SEEN
+// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+
+/*******************************************************************************
+* This file is part of NUISANCE.
+*
+* NUISANCE 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 3 of the License, or
+* (at your option) any later version.
+*
+* NUISANCE 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 NUISANCE. If not, see .
+*******************************************************************************/
+
+#include "WeightEngineBase.h"
+
+#include "systematicstools/interface/types.hh"
+
+#include "nusystematics/artless/response_helper.hh"
+
+#include
+
+class nusystWeightEngine : public WeightEngineBase {
+
+ public:
+ nusystWeightEngine();
+
+ nusyst::response_helper DUNErwt;
+
+ systtools::param_value_list_t EnabledParams;
+
+ void Config();
+
+ int ConvDial(std::string name);
+
+ // Functions requiring Override
+ void IncludeDial(std::string name, double startval);
+
+ void SetDialValue(int nuisenum, double val);
+ void SetDialValue(std::string name, double val);
+
+ bool IsDialIncluded(std::string name);
+ bool IsDialIncluded(int nuisenum);
+
+ double GetDialValue(std::string name);
+ double GetDialValue(int nuisenum);
+
+ void Reconfigure(bool silent);
+
+ bool NeedsEventReWeight();
+
+ double CalcWeight(BaseFitEvt* evt);
+
+ void Print();
+};
+
+#endif