diff --git a/cmake/NEUTSetup.cmake b/cmake/NEUTSetup.cmake index de636f5..098c889 100644 --- a/cmake/NEUTSetup.cmake +++ b/cmake/NEUTSetup.cmake @@ -1,212 +1,214 @@ # 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 . ################################################################################ find_program(neut-config NEUTCONFIGFOUND) +LIST(APPEND EXTRA_CXX_FLAGS -DNEED_FILL_NEUT_COMMONS) + SET(HAVENEUTCONFIG FALSE) # We are dealing with shiny NEUT -if(NOT NEUTCONFIGFOUND STREQUAL NEUTCONFIGFOUND-NOTFOUND) +if(NOT "${NEUTCONFIGFOUND} " STREQUAL " ") SET(HAVENEUTCONFIG TRUE) endif() if(HAVENEUTCONFIG) execute_process (COMMAND neut-config --version OUTPUT_VARIABLE NEUT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND neut-config --incdir OUTPUT_VARIABLE NEUT_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND neut-config --libdir OUTPUT_VARIABLE NEUT_LINK_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) GETLIBDIRS(neut-config --cernflags CERN_LIB_DIR) LIST(APPEND NEUT_LINK_DIRS ${CERN_LIB_DIR}) GETLIBS(neut-config --cernflags CERN_LIBS) if(USE_GENERATOR_REWEIGHT) execute_process (COMMAND neut-config --rwlibflags OUTPUT_VARIABLE NEUT_RWLIBS OUTPUT_STRIP_TRAILING_WHITESPACE) GETLIBS(neut-config --rwlibflags NEUT_RWLIBS) LIST(APPEND NEUT_LIBS ${NEUT_RWLIBS}) else() GETLIBS(neut-config --libflags NEUT_GENLIBS) GETLIBS(neut-config --iolibflags NEUT_LIBS) LIST(APPEND NEUT_LIBS ${NEUT_IOLIBS}) LIST(APPEND NEUT_LIBS ${NEUT_GENLIBS}) endif() LIST(APPEND NEUT_LIBS ${CERN_LIBS};gfortran) PrefixList(NEUT_LINK_DIRS "-L" ${NEUT_LINK_DIRS}) LIST(APPEND NEUT_CXX_FLAGS -DUSE_NEUT -DNEUT_VERSION=${NEUT_VERSION}) cmessage(STATUS "NEUT") cmessage(STATUS " Version : ${NEUT_VERSION}") cmessage(STATUS " Flags : ${NEUT_CXX_FLAGS}") cmessage(STATUS " Includes : ${NEUT_INCLUDE_DIRS}") cmessage(STATUS " Link Dirs : ${NEUT_LINK_DIRS}") cmessage(STATUS " Libs : ${NEUT_LIBS}") else() # Everything better be set up already if(NEUT_ROOT STREQUAL "") cmessage(FATAL_ERROR "Variable NEUT_ROOT is not defined. Please export environment variable NEUT_ROOT or configure with -DNEUT_ROOT=/path/to/NEUT. This must be set to point to a prebuilt NEUT instance.") endif() if(CERN STREQUAL "") cmessage(FATAL_ERROR "Variable CERN is not defined. Please export environment variable CERN or configure with -DCERN=/path/to/CERNLIB. This must be set to point to a prebuilt CERNLIB instance.") endif() if(CERN_LEVEL STREQUAL "") cmessage(FATAL_ERROR "Variable CERN_LEVEL is not defined. Please export environment variable CERN_LEVEL or configure with -DCERN_LEVEL=XXXX (likely to be 2005).") endif() if(${NEUT_VERSION} VERSION_LESS 5.4.0) set(NEUT_LIB_DIR ${NEUT_ROOT}/lib/Linux_pc) else() set(NEUT_LIB_DIR ${NEUT_ROOT}/lib) endif() set(NEUT_CLASS ${NEUT_ROOT}/src/neutclass) LIST(APPEND NEUT_INCLUDE_DIRS ${NEUT_ROOT}/include ${NEUT_ROOT}/src/neutclass) LIST(APPEND NEUT_LINK_DIRS ${NEUT_LIB_DIR} ${CERN}/${CERN_LEVEL}/lib) if(${NEUT_VERSION} VERSION_GREATER 5.4.1.999) LIST(APPEND NEUT_LIBS neutcore_5.4.2 nuccorspl_5.4.2 #typo in NEUT, may hopefully disappear nuceff_5.4.2 partnuck_5.4.2 skmcsvc_5.4.2 tauola_5.4.2 HT2p2h_5.4.0 N1p1h_5.4.0) LIST(APPEND NEUT_CXX_FLAGS -DNEUT_COMMON_QEAV) elseif(${NEUT_VERSION} VERSION_EQUAL 5.4.1) LIST(APPEND NEUT_LIBS neutcore_5.4.1 nuccorspl_5.4.1 #typo in NEUT, may hopefully disappear nuceff_5.4.1 partnuck_5.4.1 skmcsvc_5.4.1 tauola_5.4.1 HT2p2h_5.4.1 N1p1h_5.4.1) elseif(${NEUT_VERSION} VERSION_GREATER 5.3.999) LIST(APPEND NEUT_LIBS neutcore_5.4.0 nuccorspl_5.4.0 #typo in NEUT, may hopefully disappear nuceff_5.4.0 partnuck_5.4.0 skmcsvc_5.4.0 tauola_5.4.0 HT2p2h_5.4.0 N1p1h_5.4.0) else() LIST(APPEND NEUT_LIBS neutcore nuccorrspl nuceff partnuck skmcsvc tauola) endif() LIST(APPEND NEUT_LIBS jetset74 pdflib804 mathlib packlib pawlib gfortran) if(USE_GENERATOR_REWEIGHT) LIST(APPEND NEUT_INCLUDE_DIRS ${NEUT_ROOT}/src/reweight) LIST(APPEND NEUT_LINK_DIRS ${NEUT_ROOT}/src/reweight) LIST(REVERSE NEUT_LIBS) LIST(APPEND NEUT_LIBS NReWeight) LIST(REVERSE NEUT_LIBS) endif() set(NEUT_ROOT_SHAREDOBJS) LIST(APPEND NEUT_ROOT_SHAREDOBJS ${NEUT_CLASS}/neutctrl.so ${NEUT_CLASS}/neutfsivert.so) # Check for new versions of NEUT with NUCLEON FSI if(EXISTS "${NEUT_CLASS}/neutnucfsistep.so") set(NEUT_NUCFSI 1) LIST(APPEND NEUT_CXX_FLAGS -DNEUT_NUCFSI_ENABLED) LIST(APPEND NEUT_ROOT_SHAREDOBJS ${NEUT_CLASS}/neutnucfsistep.so ${NEUT_CLASS}/neutnucfsivert.so ) endif() if(${NEUT_VERSION} VERSION_LESS 5.4.0) LIST(APPEND NEUT_ROOT_SHAREDOBJS ${NEUT_CLASS}/neutrootTreeSingleton.so) endif() LIST(APPEND NEUT_ROOT_SHAREDOBJS ${NEUT_CLASS}/neutvtx.so ${NEUT_CLASS}/neutfsipart.so ${NEUT_CLASS}/neutpart.so ${NEUT_CLASS}/neutvect.so ) foreach(so ${NEUT_ROOT_SHAREDOBJS}) get_filename_component(SONAME ${so} NAME_WE) add_library(${SONAME} SHARED IMPORTED) set_property(TARGET ${SONAME} PROPERTY IMPORTED_LOCATION ${so}) LIST(APPEND NEUT_IMPORTED_TARGETS ${SONAME}) endforeach() PrefixList(NEUT_LINK_DIRS "-L" ${NEUT_LINK_DIRS}) LIST(APPEND NEUT_CXX_FLAGS -DUSE_NEUT -DNEUT_VERSION=${NEUT_VERSION}) cmessage(STATUS "NEUT") cmessage(STATUS " Version : ${NEUT_VERSION}") cmessage(STATUS " Flags : ${NEUT_CXX_FLAGS}") cmessage(STATUS " Includes : ${NEUT_INCLUDE_DIRS}") cmessage(STATUS " Link Dirs : ${NEUT_LINK_DIRS}") cmessage(STATUS " Libs : ${NEUT_LIBS}") cmessage(STATUS " SOs : ${NEUT_IMPORTED_TARGETS}") endif() -SET(USE_NEUT TRUE CACHE BOOL "Whether to enable GENIE support. Requires external libraries. " FORCE) +SET(USE_NEUT TRUE CACHE BOOL "Whether to enable NEUT support. Requires external libraries. " FORCE) diff --git a/cmake/T2KReWeightSetup.cmake b/cmake/T2KReWeightSetup.cmake new file mode 100644 index 0000000..0b55f96 --- /dev/null +++ b/cmake/T2KReWeightSetup.cmake @@ -0,0 +1,22 @@ +if(T2KREWEIGHT STREQUAL "") + cmessage(FATAL_ERROR "Requested T2KReWeight support, but T2KREWEIGHT variable is not defined, either pass at configure time, or configure with it declared as an environment variable (rm CMakeCache.txt if it is currently defined as an environment variable and you still see this message.)") +endif() + +SET(T2K_INCLUDE_DIRS) +SET(T2K_LINK_DIRS) +SET(T2K_LIBS) + +LIST(APPEND T2K_INCLUDE_DIRS ${T2KREWEIGHT}/src) +LIST(APPEND T2K_LINK_DIRS ${T2KREWEIGHT}/lib) +LIST(APPEND T2K_LIBS T2KReWeight) + +if(NIWG STREQUAL "") + SET(USE_NIWG FALSE CACHE INTERNAL "Whether we are using the T2K NIWGReWeight. " FORCE) +else() + SET(USE_NIWG TRUE CACHE INTERNAL "Whether we are using the T2K NIWGReWeight. " FORCE) + LIST(APPEND T2K_INCLUDE_DIRS ${NIWG}) + LIST(APPEND T2K_LINK_DIRS ${NIWG}) + LIST(APPEND T2K_LIBS NIWGReWeight) +endif() + +PrefixList(T2K_LINK_DIRS "-L" ${T2K_LINK_DIRS}) diff --git a/cmake/cacheVariables.cmake b/cmake/cacheVariables.cmake index 336be79..87c0b72 100644 --- a/cmake/cacheVariables.cmake +++ b/cmake/cacheVariables.cmake @@ -1,116 +1,122 @@ # Copyright 2018 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() # Misc CheckAndSetDefaultCache(EXTRA_SETUP_SCRIPT "" PATH "The path to an extra script to inject into the NUISANCE setup script. <>") CheckAndSetDefaultCache(USE_MINIMIZER TRUE INTERNAL "Whether we are using the ROOT minimization libraries. ") CheckAndSetDefaultCache(USE_GENERATOR_REWEIGHT TRUE BOOL "Whether we are using the generator reweighting libraries. ") CheckAndSetDefaultCache(USE_ROOT6 FALSE INTERNAL "Whether we are using the ROOT 6. ") # NuWro 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) # NEUT 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) +# T2K +CheckAndSetDefaultCache(USE_T2K FALSE BOOL "Whether to enable T2KReWeight support. Requires external libraries. ") +CheckAndSetDefaultEnv(T2KREWEIGHT "" PATH "Path to T2K binary tree root directory. Overrides environment variable \$T2KREWEIGHT <>" T2KREWEIGHT) +CheckAndSetDefaultCache(USE_NIWG FALSE INTERNAL "Whether we are using the T2K NIWGReWeight. ") +CheckAndSetDefaultEnv(NIWG "" PATH "Path to NIWGReWeight binary tree root directory. Overrides environment variable \$NIWG <>" NIWG) + # GENIE CheckAndSetDefaultCache(USE_GENIE FALSE BOOL "Whether to enable GENIE (reweight) 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) 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) # Pythia CheckAndSetDefaultEnv(PYTHIA6 "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>" PYTHIA6) CheckAndSetDefault(NEED_PYTHIA6 FALSE) CheckAndSetDefault(NEED_ROOTEVEGEN FALSE) CheckAndSetDefault(NEED_ROOTPYTHIA6 FALSE) diff --git a/scripts/to_configure/setup.sh.in b/scripts/to_configure/setup.sh.in index e17e0a3..25c22c8 100644 --- a/scripts/to_configure/setup.sh.in +++ b/scripts/to_configure/setup.sh.in @@ -1,155 +1,168 @@ # 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_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_T2K@" != "FALSE" ]; then + echo "[INFO]: Adding T2KReWeight library paths to the environment." + export T2KREWEIGHT=@T2KREWEIGHT@ + add_to_LD_LIBRARY_PATH "${T2KREWEIGHT}/lib" + + if [ "@USE_NIWG@" != "FALSE" ]; then + echo "[INFO]: Adding NIWGReWeight library paths to the environment." + export NIWG=@NIWG@ + export NIWGREWEIGHT_INPUTS=@NIWG@/inputs + add_to_LD_LIBRARY_PATH "${NIWG}" + fi +fi + if [ "@USE_NUWRO@" != "FALSE" ]; then echo "[INFO]: Adding NuWro library paths to the environment." export NUWRO="@NUWRO@" add_to_PATH "@NUWRO@/bin" # NuWro puts event1.so into the bin directoy. add_to_LD_LIBRARY_PATH "@NUWRO@/bin" if [ "@NUWRO_INC@" ]; then export NUWRO_INC=@NUWRO_INC@ 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 [ "@GSL_INC@" ]; then export GSL_INC="@GSL_INC@" fi if [ "@GSL_LIB@" ]; then export GSL_LIB="@GSL_LIB@" fi 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 echo "[INFO]: Adding GENIE ReWeight library paths to the environment." export GENIE_REWEIGHT="@GENIE_REWEIGHT@" add_to_LD_LIBRARY_PATH "@GENIE_REWEIGHT@/lib" fi if [ "@GSL_LIB@" ]; then add_to_LD_LIBRARY_PATH "@GSL_LIB@" fi fi source @CMAKE_INSTALL_PREFIX@/fhiclcpp.setup.sh add_to_FHICL_FILE_PATH @CMAKE_INSTALL_PREFIX@/fcl export NUISANCE="@CMAKE_SOURCE_DIR@" diff --git a/src/app/nuisflat.cxx b/src/app/nuisflat.cxx index 5d36dad..1ebbbda 100644 --- a/src/app/nuisflat.cxx +++ b/src/app/nuisflat.cxx @@ -1,83 +1,119 @@ #include "config/GlobalConfiguration.hxx" #include "input/IInputHandler.hxx" #include "event/MinimalEvent.hxx" #include "samples/IEventProcessor.hxx" #include "plugins/Instantiate.hxx" #include "persistency/ROOTOutput.hxx" #include "exception/exception.hxx" +#include "variation/WeightManager.hxx" + #include "fhiclcpp/make_ParameterSet.h" #include "string_parsers/from_string.hxx" #include NEW_NUIS_EXCEPT(invalid_cli_arguments); size_t NMax = std::numeric_limits::max(); -std::string input_file; -std::string input_type; +std::string input_file = ""; +std::string input_type = ""; +std::string default_stream_override = ""; +std::string variation_config_file = ""; void SayUsage(char const *argv[]) { std::cout << "[USAGE]: " << argv[0] << "\n" "\t-i : Input file passed to named " "IInputHandler instance \n" "\t-H : Name of IInputHandler subclass " "capable of reading NUISANCE events from the argument of -i.\n" "\t-n : Maximum number of events to " "read. Will read entire input file by default.\n" + "\t-o : Default output stream name " + "override, if unspecified mode will be 'CREATE'. \n" + "\t--variation-config : Read weight engine state from " + "input fhicl file. \n" << std::endl; } void handleOpts(int argc, char const *argv[]) { int opt = 1; while (opt < argc) { if ((std::string(argv[opt]) == "-?") || (std::string(argv[opt]) == "--help")) { SayUsage(argv); exit(0); } else if (std::string(argv[opt]) == "-i") { input_file = argv[++opt]; } else if (std::string(argv[opt]) == "-H") { input_type = argv[++opt]; } else if (std::string(argv[opt]) == "-n") { NMax = fhicl::string_parsers::str2T(argv[++opt]); + } else if (std::string(argv[opt]) == "-o") { + default_stream_override = argv[++opt]; + } else if (std::string(argv[opt]) == "--variation-config") { + variation_config_file = argv[++opt]; } else { std::cout << "[ERROR]: Unknown option: " << argv[opt] << std::endl; SayUsage(argv); exit(1); } opt++; } } int main(int argc, char const *argv[]) { nuis::config::EnsureConfigurationRead("nuis.global.config.fcl"); handleOpts(argc, argv); if (!input_type.length() || !input_file.length()) { SayUsage(argv); throw invalid_cli_arguments() << "[ERROR]: Require both -i and -H cli options to be passed."; } + if (default_stream_override.size()) { + std::vector split = + nuis::utility::split(default_stream_override, ":"); + std::string open_mode = (split.size() > 1) ? split[1] : "CREATE"; + + nuis::persistency::NewStream("default", split[0], open_mode); + } + + fhicl::ParameterSet const &global_config = nuis::config::GetDocument(); + + if (variation_config_file.size()) { + nuis::config::EnsureConfigurationRead(variation_config_file); + + if (global_config.has_key("weight_engines")) { + for (fhicl::ParameterSet const &we_ps : + global_config.get>( + "weight_engines")) { + nuis::variation::WeightManager::Get().EnsureWeightProviderLoaded(we_ps); + } + nuis::variation::WeightManager::Get().ReconfigureWeightEngines(); + } + } + fhicl::ParameterSet sample_config; sample_config.put("input_type", input_type); sample_config.put("file", input_file); - nuis::plugins::plugin_traits::unique_ptr_t VerboseEventSummary = - nuis::plugins::Instantiate("EventSummary_ECTJune2019"); + nuis::plugins::plugin_traits::unique_ptr_t + VerboseEventSummary = nuis::plugins::Instantiate( + "EventSummary_ECTJune2019"); VerboseEventSummary->Initialize(sample_config); VerboseEventSummary->ProcessSample(NMax); nuis::persistency::CloseOpenTFiles(); } diff --git a/src/generator/variation/FillNEUTCommons.hxx b/src/generator/variation/FillNEUTCommons.hxx index 3b45df5..dc67fb0 100644 --- a/src/generator/variation/FillNEUTCommons.hxx +++ b/src/generator/variation/FillNEUTCommons.hxx @@ -1,161 +1,162 @@ #pragma once #include "NFortFns.h" // Contains all the NEUT common blocks +#include "neutvect.h" namespace NEUTUtils { inline void FillNeutCommons(NeutVect const *nvect_const) { // WARNING: This has only been implemented for a neuttree and not GENIE // This should be kept in sync with T2KNIWGUtils::GetNIWGEvent(TTree) // NEUT version info. Can't get it to compile properly with this yet // neutversion_.corev = nvect->COREVer; // neutversion_.nucev = nvect->NUCEVer; // neutversion_.nuccv = nvect->NUCCVer; // Documentation: See nework.h // Dangerous... but hoping that these methods don't actually modify the // vector. NeutVect *nvect = const_cast(nvect_const); nework_.modene = nvect->Mode; nework_.numne = nvect->Npart(); #ifdef NEUT_COMMON_QEAV nemdls_.mdlqeaf = nvect->QEAVForm; #else nemdls_.mdlqeaf = nvect->QEVForm; #endif nemdls_.mdlqe = nvect->QEModel; nemdls_.mdlspi = nvect->SPIModel; nemdls_.mdldis = nvect->DISModel; nemdls_.mdlcoh = nvect->COHModel; neutcoh_.necohepi = nvect->COHModel; nemdls_.xmaqe = nvect->QEMA; nemdls_.xmvqe = nvect->QEMV; nemdls_.kapp = nvect->KAPPA; // nemdls_.sccfv = SCCFVdef; // nemdls_.sccfa = SCCFAdef; // nemdls_.fpqe = FPQEdef; nemdls_.xmaspi = nvect->SPIMA; nemdls_.xmvspi = nvect->SPIMV; nemdls_.xmares = nvect->RESMA; nemdls_.xmvres = nvect->RESMV; neut1pi_.xmanffres = nvect->SPIMA; neut1pi_.xmvnffres = nvect->SPIMV; neut1pi_.xmarsres = nvect->RESMA; neut1pi_.xmvrsres = nvect->RESMV; neut1pi_.neiff = nvect->SPIForm; neut1pi_.nenrtype = nvect->SPINRType; neut1pi_.rneca5i = nvect->SPICA5I; neut1pi_.rnebgscl = nvect->SPIBGScale; nemdls_.xmacoh = nvect->COHMA; nemdls_.rad0nu = nvect->COHR0; // nemdls_.fa1coh = nvect->COHA1err; // nemdls_.fb1coh = nvect->COHb1err; // neutdis_.nepdf = NEPDFdef; // neutdis_.nebodek = NEBODEKdef; neutcard_.nefrmflg = nvect->FrmFlg; neutcard_.nepauflg = nvect->PauFlg; neutcard_.nenefo16 = nvect->NefO16; neutcard_.nemodflg = nvect->ModFlg; // neutcard_.nenefmodl = 1; // neutcard_.nenefmodh = 1; // neutcard_.nenefkinh = 1; // neutpiabs_.neabspiemit = 1; nenupr_.iformlen = nvect->FormLen; neutpiless_.ipilessdcy = nvect->IPilessDcy; neutpiless_.rpilessdcy = nvect->RPilessDcy; neutpiless_.ipilessdcy = nvect->IPilessDcy; neutpiless_.rpilessdcy = nvect->RPilessDcy; neffpr_.fefqe = nvect->NuceffFactorPIQE; neffpr_.fefqeh = nvect->NuceffFactorPIQEH; neffpr_.fefinel = nvect->NuceffFactorPIInel; neffpr_.fefabs = nvect->NuceffFactorPIAbs; neffpr_.fefcx = nvect->NuceffFactorPICX; neffpr_.fefcxh = nvect->NuceffFactorPICXH; neffpr_.fefcoh = nvect->NuceffFactorPICoh; neffpr_.fefqehf = nvect->NuceffFactorPIQEHKin; neffpr_.fefcxhf = nvect->NuceffFactorPICXKin; neffpr_.fefcohf = nvect->NuceffFactorPIQELKin; for (int i = 0; i < nework_.numne; i++) { nework_.ipne[i] = nvect->PartInfo(i)->fPID; nework_.pne[i][0] = (float)nvect->PartInfo(i)->fP.X() / 1000; // VC(NE)WORK in M(G)eV nework_.pne[i][1] = (float)nvect->PartInfo(i)->fP.Y() / 1000; // VC(NE)WORK in M(G)eV nework_.pne[i][2] = (float)nvect->PartInfo(i)->fP.Z() / 1000; // VC(NE)WORK in M(G)eV } // fsihist.h // neutroot fills a dummy object for events with no FSI to prevent memory leak // when // reading the TTree, so check for it here if ((int)nvect->NfsiVert() == 1) { // An event with FSI must have at least two vertices // if (nvect->NfsiPart()!=1 || nvect->Fsiprob!=-1) // ERR(WRN) << "T2KNeutUtils::fill_neut_commons(TTree) NfsiPart!=1 or // Fsiprob!=-1 when NfsiVert==1" << std::endl; fsihist_.nvert = 0; fsihist_.nvcvert = 0; fsihist_.fsiprob = 1; } else { // Real FSI event fsihist_.nvert = (int)nvect->NfsiVert(); for (int ivert = 0; ivert < fsihist_.nvert; ivert++) { fsihist_.iflgvert[ivert] = nvect->FsiVertInfo(ivert)->fVertID; fsihist_.posvert[ivert][0] = (float)nvect->FsiVertInfo(ivert)->fPos.X(); fsihist_.posvert[ivert][1] = (float)nvect->FsiVertInfo(ivert)->fPos.Y(); fsihist_.posvert[ivert][2] = (float)nvect->FsiVertInfo(ivert)->fPos.Z(); } fsihist_.nvcvert = nvect->NfsiPart(); for (int ip = 0; ip < fsihist_.nvcvert; ip++) { fsihist_.abspvert[ip] = (float)nvect->FsiPartInfo(ip)->fMomLab; fsihist_.abstpvert[ip] = (float)nvect->FsiPartInfo(ip)->fMomNuc; fsihist_.ipvert[ip] = nvect->FsiPartInfo(ip)->fPID; fsihist_.iverti[ip] = nvect->FsiPartInfo(ip)->fVertStart; fsihist_.ivertf[ip] = nvect->FsiPartInfo(ip)->fVertEnd; fsihist_.dirvert[ip][0] = (float)nvect->FsiPartInfo(ip)->fDir.X(); fsihist_.dirvert[ip][1] = (float)nvect->FsiPartInfo(ip)->fDir.Y(); fsihist_.dirvert[ip][2] = (float)nvect->FsiPartInfo(ip)->fDir.Z(); } fsihist_.fsiprob = nvect->Fsiprob; } neutcrscom_.crsx = nvect->Crsx; neutcrscom_.crsy = nvect->Crsy; neutcrscom_.crsz = nvect->Crsz; neutcrscom_.crsphi = nvect->Crsphi; neutcrscom_.crsq2 = nvect->Crsq2; neuttarget_.numbndn = nvect->TargetA - nvect->TargetZ; neuttarget_.numbndp = nvect->TargetZ; neuttarget_.numfrep = nvect->TargetH; neuttarget_.numatom = nvect->TargetA; posinnuc_.ibound = nvect->Ibound; // put empty nucleon FSI history (since it is not saved in the NeutVect // format) // Comment out as NEUT does not have the necessary proton FSI information yet // nucleonfsihist_.nfnvert = 0; // nucleonfsihist_.nfnstep = 0; } } // namespace NEUTUtils diff --git a/src/generator/variation/NEUTWeightEngine.cxx b/src/generator/variation/NEUTWeightEngine.cxx index a8baff8..9d8f857 100644 --- a/src/generator/variation/NEUTWeightEngine.cxx +++ b/src/generator/variation/NEUTWeightEngine.cxx @@ -1,121 +1,128 @@ #include "generator/variation/NEUTWeightEngine.hxx" + +#ifdef NEED_FILL_NEUT_COMMONS #include "generator/variation/FillNEUTCommons.hxx" +#include "neutvect.h" +#else +#include "neutread.h" +#endif #include "fhiclcpp/ParameterSet.h" #include "event/MinimalEvent.hxx" // NEUT Engine includes #include "NReWeight.h" #include "NReWeightCasc.h" #include "NReWeightNuXSecCCQE.h" #include "NReWeightNuXSecCCRES.h" #include "NReWeightNuXSecCOH.h" #include "NReWeightNuXSecDIS.h" #include "NReWeightNuXSecNC.h" #include "NReWeightNuXSecNCEL.h" #include "NReWeightNuXSecNCRES.h" #include "NReWeightNuXSecRES.h" #include "NReWeightNuclPiless.h" -#include "NSystUncertainty.h" - #include using namespace nuis; using namespace nuis::params; using namespace nuis::event; void NEUTWeightEngine::Initialize(fhicl::ParameterSet const &ps) { fNeutRW = std::make_unique(); TDirectory *dir = gDirectory; fNeutRW->AdoptWghtCalc("xsec_ccqe", new neut::rew::NReWeightNuXSecCCQE); fNeutRW->AdoptWghtCalc("xsec_res", new neut::rew::NReWeightNuXSecRES); fNeutRW->AdoptWghtCalc("xsec_ccres", new neut::rew::NReWeightNuXSecCCRES); fNeutRW->AdoptWghtCalc("xsec_coh", new neut::rew::NReWeightNuXSecCOH); fNeutRW->AdoptWghtCalc("xsec_dis", new neut::rew::NReWeightNuXSecDIS); fNeutRW->AdoptWghtCalc("xsec_ncel", new neut::rew::NReWeightNuXSecNCEL); fNeutRW->AdoptWghtCalc("xsec_nc", new neut::rew::NReWeightNuXSecNC); fNeutRW->AdoptWghtCalc("xsec_ncres", new neut::rew::NReWeightNuXSecNCRES); fNeutRW->AdoptWghtCalc("nucl_casc", new neut::rew::NReWeightCasc); fNeutRW->AdoptWghtCalc("nucl_piless", new neut::rew::NReWeightNuclPiless); dir->cd(); for (fhicl::ParameterSet param_ps : ps.get>("parameters")) { param_ps.put("type", GetName()); std::string const ¶m_name = param_ps.get("name"); NEUTSystParam nsp; nsp.nsyst = neut::rew::NSyst::FromString(param_name); if (nsp.nsyst == neut::rew::kNullSystematic) { throw invalid_NEUT_syst_name() << "[ERROR]: NReWeight failed to parse " << std::quoted(param_name) << " as a NEUT dial."; } fNeutRW->Systematics().Init(nsp.nsyst); nsp.pid = ParameterManager::Get().EnsureParameterRegistered(param_ps); fNEUTSysts.push_back(nsp); } Reconfigure(); } void NEUTWeightEngine::Reconfigure() { for (NEUTSystParam const &nsp : fNEUTSysts) { double val = ParameterManager::Get().GetParameterValue(nsp.pid); fNeutRW->Systematics().Set(nsp.nsyst, val); } fNeutRW->Reconfigure(); } double NEUTWeightEngine::GetEventWeight(nuis::event::MinimalEvent const &ev) { NeutVect const *nv = static_cast(ev.fGenEvent); if (!nv) { return 1.0; } +#ifdef NEED_FILL_NEUT_COMMONS NEUTUtils::FillNeutCommons(nv); +#else + neutread(nv); +#endif return fNeutRW->CalcWeight(); } std::string NEUTWeightEngine::GetName() { return "NEUTWeightEngine"; } std::string NEUTWeightEngine::GetDocumentation() { return ""; } fhicl::ParameterSet NEUTWeightEngine::GetExampleConfiguration() { fhicl::ParameterSet ps; ps.put("name", GetName()); - ps.put("use_LMCPiBar_BgScl",false); fhicl::ParameterSet dial_maqe; dial_maqe.put("name", "MaCCQE"); dial_maqe.put("start", 0); dial_maqe.put("min", -3); dial_maqe.put("max", 3); dial_maqe.put("step", 0.1); fhicl::ParameterSet dial_mares; dial_mares.put("name", "MARES"); dial_mares.put("start", 0); dial_mares.put("min", -3); dial_mares.put("max", 3); dial_mares.put("step", 0.1); ps.put>( "parameters", std::vector{{dial_maqe, dial_mares}}); return ps; } GeneratorManager::Generator_id_t NEUTWeightEngine::GetGeneratorId() { return GeneratorManager::Get().EnsureGeneratorRegistered("NEUT"); } DECLARE_PLUGIN(IWeightProvider, NEUTWeightEngine); diff --git a/src/variation/CMakeLists.txt b/src/variation/CMakeLists.txt index fe425d0..326e27f 100644 --- a/src/variation/CMakeLists.txt +++ b/src/variation/CMakeLists.txt @@ -1,14 +1,16 @@ SET(variation_implementation_files IWeightProvider.cxx WeightManager.cxx) SET(variation_header_files WeightManager.hxx IVariationProvider.hxx IWeightProvider.hxx) add_library(nuis_variation SHARED ${variation_implementation_files}) target_link_libraries(nuis_variation nuis_event nuis_plugins) install(TARGETS nuis_variation DESTINATION lib) install(FILES ${variation_header_files} DESTINATION include/variation) + +add_subdirectory(engines) diff --git a/src/variation/engines/CMakeLists.txt b/src/variation/engines/CMakeLists.txt new file mode 100644 index 0000000..0a7b62b --- /dev/null +++ b/src/variation/engines/CMakeLists.txt @@ -0,0 +1,39 @@ +if(USE_T2K) + include(${CMAKE_SOURCE_DIR}/cmake/T2KReWeightSetup.cmake) + LIST(APPEND WEIGHT_ENGINES_IMPL T2KReWeight.cxx) + LIST(APPEND WEIGHT_ENGINES_LINK_LIBS nuis_generator_utility) +endif(USE_T2K) + +if(WEIGHT_ENGINES_IMPL) + add_library(variation_engines SHARED ${WEIGHT_ENGINES_IMPL}) + target_link_libraries(variation_engines ${WEIGHT_ENGINES_LINK_LIBS}) + + if(USE_NEUT) + target_compile_options(variation_engines PUBLIC ${NEUT_CXX_FLAGS}) + include_directories(${NEUT_INCLUDE_DIRS}) + + target_link_libraries(variation_engines ${NEUT_LINK_DIRS}) + target_link_libraries(variation_engines -Wl,--no-as-needed ${NEUT_LIBS}) + target_link_libraries(variation_engines ${NEUT_IMPORTED_TARGETS}) + endif() + + if(USE_T2K) + include_directories(${T2K_INCLUDE_DIRS}) + + target_link_libraries(variation_engines ${T2K_LINK_DIRS}) + target_link_libraries(variation_engines ${T2K_LIBS}) + endif() + + if(USE_NUWRO) + target_compile_options(variation_engines PUBLIC ${NUWRO_CXX_FLAGS}) + include_directories(${NUWRO_INCLUDE_DIRS}) + target_link_libraries(variation_engines -Wl,--no-as-needed ${NUWRO_IMPORTED_TARGETS}) + endif() + + if(${NEED_PYTHIA6}) + target_link_libraries(variation_engines -L${PYTHIA6}) + endif() + target_link_libraries(variation_engines -L${ROOT_LIBDIR} ${ROOT_LIBS}) + + install(TARGETS variation_engines DESTINATION plugins) +endif() diff --git a/src/variation/engines/T2KReWeight.cxx b/src/variation/engines/T2KReWeight.cxx new file mode 100644 index 0000000..71eda4e --- /dev/null +++ b/src/variation/engines/T2KReWeight.cxx @@ -0,0 +1,102 @@ +#include "variation/engines/T2KReWeight.hxx" + +#include "fhiclcpp/ParameterSet.h" + +#include "event/MinimalEvent.hxx" + +// T2K Engine includes +#include "T2KNeutReWeight.h" +#include "T2KNIWGReWeight.h" +#include "T2KReWeight.h" + +#include + +using namespace nuis; +using namespace nuis::params; +using namespace nuis::event; + +void T2KReWeightEngine::Initialize(fhicl::ParameterSet const &ps) { + + fT2KRW = std::make_unique(); + TDirectory *dir = gDirectory; + fT2KRW->AdoptWghtEngine("NEUT", new t2krew::T2KNeutReWeight); + fT2KRW->AdoptWghtEngine("NIWG", new t2krew::T2KNIWGReWeight); + dir->cd(); + + + for (fhicl::ParameterSet param_ps : + ps.get>("parameters")) { + + param_ps.put("type", GetName()); + + std::string const ¶m_name = param_ps.get("name"); + + T2KSystParam tsp; + + tsp.t2ksyst = t2krew::T2KSyst::FromString(param_name); + + if (tsp.t2ksyst == t2krew::kSystNull) { + throw invalid_T2K_syst_name() + << "[ERROR]: T2KReWeight failed to parse " << std::quoted(param_name) + << " as a T2K dial."; + } + fT2KRW->Systematics().Include(tsp.t2ksyst); + + tsp.pid = ParameterManager::Get().EnsureParameterRegistered(param_ps); + + fT2KSysts.push_back(tsp); + } + + Reconfigure(); +} +void T2KReWeightEngine::Reconfigure() { + + for (T2KSystParam const &tsp : fT2KSysts) { + double val = ParameterManager::Get().GetParameterValue(tsp.pid); + fT2KRW->Systematics().SetTwkDial(tsp.t2ksyst, val); + } + + fT2KRW->Reconfigure(); +} +double T2KReWeightEngine::GetEventWeight(nuis::event::MinimalEvent const &ev) { + NeutVect const *nv = static_cast(ev.fGenEvent); + if (!nv) { + return 1.0; + } + NeutVect *nv_nc = const_cast(nv); + return fT2KRW->CalcWeight(nv_nc); +} + +std::string T2KReWeightEngine::GetName() { return "T2KReWeightEngine"; } +std::string T2KReWeightEngine::GetDocumentation() { return ""; } +fhicl::ParameterSet T2KReWeightEngine::GetExampleConfiguration() { + fhicl::ParameterSet ps; + + ps.put("name", GetName()); + fhicl::ParameterSet dial_maqe; + dial_maqe.put("name", "NXSec_MaCCQE"); + + dial_maqe.put("start", 0); + dial_maqe.put("min", -3); + dial_maqe.put("max", 3); + dial_maqe.put("step", 0.1); + + fhicl::ParameterSet dial_mares; + dial_mares.put("name", "NXSec_MARES"); + + dial_mares.put("start", 0); + dial_mares.put("min", -3); + dial_mares.put("max", 3); + dial_mares.put("step", 0.1); + + ps.put>( + "parameters", std::vector{{dial_maqe, dial_mares}}); + + return ps; +} + +GeneratorManager::Generator_id_t T2KReWeightEngine::GetGeneratorId() { + return GeneratorManager::Get().EnsureGeneratorRegistered("NEUT"); +} + +DECLARE_PLUGIN(IWeightProvider, T2KReWeightEngine); diff --git a/src/variation/engines/T2KReWeight.hxx b/src/variation/engines/T2KReWeight.hxx new file mode 100644 index 0000000..0fa2e29 --- /dev/null +++ b/src/variation/engines/T2KReWeight.hxx @@ -0,0 +1,60 @@ +// Copyright 2018 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 . + *******************************************************************************/ + +#ifndef GENERATOR_VARIATION_NEUTREWEIGHT_HXX_SEEN +#define GENERATOR_VARIATION_NEUTREWEIGHT_HXX_SEEN + +#include "variation/IWeightProvider.hxx" + +#include "exception/exception.hxx" + +#include "parameters/ParameterManager.hxx" + +#include "T2KSyst.h" + +#include +#include + +namespace t2krew { +class T2KReWeight; +} + +class T2KReWeightEngine : public IWeightProvider { + + struct T2KSystParam { + nuis::params::paramId_t pid; + t2krew::T2KSyst_t t2ksyst; + }; + + std::vector fT2KSysts; + std::unique_ptr fT2KRW; + +public: + NEW_NUIS_EXCEPT(invalid_T2K_syst_name); + + void Initialize(fhicl::ParameterSet const &); + void Reconfigure(); + double GetEventWeight(nuis::event::MinimalEvent const &); + std::string GetName(); + std::string GetDocumentation(); + fhicl::ParameterSet GetExampleConfiguration(); + nuis::GeneratorManager::Generator_id_t GetGeneratorId(); +}; + +#endif