diff --git a/cmake/ReweightEnginesSetup.cmake b/cmake/ReweightEnginesSetup.cmake
index 3efc7c8..59f745a 100644
--- a/cmake/ReweightEnginesSetup.cmake
+++ b/cmake/ReweightEnginesSetup.cmake
@@ -1,101 +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)
+if(USE_NUSYST)
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)
+ set(USE_NUSYST 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 cce141d..c0e8a11 100644
--- a/cmake/cacheVariables.cmake
+++ b/cmake/cacheVariables.cmake
@@ -1,245 +1,247 @@
# 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_NUSYST FALSE BOOL "Whether to enable DUNE Reweight support. ")
+CheckAndSetDefaultEnv(NUSYST_ROOT "" PATH "Path to nusystematics install directory <>" NUSYST_ROOT)
+CheckAndSetDefaultEnv(SYSTTOOLS_ROOT "" PATH "Path to systematicstools install directory <>" SYSTTOOLS_ROOT)
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
index 6e4f9af..a15790c 100644
--- a/cmake/nusystematicsSetup.cmake
+++ b/cmake/nusystematicsSetup.cmake
@@ -1,37 +1,39 @@
# 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.")
+if(NUSYST_ROOT STREQUAL "")
+ cmessage(FATAL_ERROR "Variable NUSYST_ROOT is not defined. Either configure with -DNUSYST_ROOT or \"\$ export NUSYST_ROOT=/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.")
+if(SYSTTOOLS_ROOT STREQUAL "")
+ cmessage(FATAL_ERROR "Variable SYSTTOOLS_ROOT is not defined. Either configure with -DSYSTTOOLS_ROOT or \"\$ export SYSTTOOLS_ROOT=/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 EXTRA_CXX_FLAGS -D__NUSYST_ENABLED__ -DNO_ART -std=c++1y -Wno-deprecated-declarations -Wno-deprecated)
-LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUSYSTROOT}/include ${SYSTTOOLSROOT}/include)
+LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES
+ ${NUSYST_ROOT}/include
+ ${SYSTTOOLS_ROOT}/include)
-LIST(APPEND EXTRA_LINK_DIRS ${NUSYSTROOT}/lib ${SYSTTOOLSROOT}/lib)
+LIST(APPEND EXTRA_LINK_DIRS ${NUSYST_ROOT}/lib ${SYSTTOOLS_ROOT}/lib)
LIST(APPEND EXTRA_LIBS nusystematics_systproviders
systematicstools_interface
systematicstools_interpreters
systematicstools_systproviders
systematicstools_utility)
diff --git a/src/Reweight/CMakeLists.txt b/src/Reweight/CMakeLists.txt
index 17624bd..1fe47ae 100644
--- a/src/Reweight/CMakeLists.txt
+++ b/src/Reweight/CMakeLists.txt
@@ -1,96 +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)
+if(USE_NUSYST)
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/FitWeight.cxx b/src/Reweight/FitWeight.cxx
index 5518e2a..79c1504 100644
--- a/src/Reweight/FitWeight.cxx
+++ b/src/Reweight/FitWeight.cxx
@@ -1,290 +1,305 @@
#include "FitWeight.h"
#include "GENIEWeightEngine.h"
#include "LikelihoodWeightEngine.h"
#include "ModeNormEngine.h"
#include "NEUTWeightEngine.h"
#include "NIWGWeightEngine.h"
#include "NUISANCEWeightEngine.h"
#include "NuWroWeightEngine.h"
#include "OscWeightEngine.h"
#include "SampleNormEngine.h"
#include "SplineWeightEngine.h"
#include "T2KWeightEngine.h"
#ifdef __NOVA_ENABLED__
#include "NOvARwgtEngine.h"
#endif
+#ifdef __NUSYST_ENABLED__
+#include "nusystematicsWeightEngine.h"
+#endif
+
void FitWeight::AddRWEngine(int type) {
NUIS_LOG(FIT, "Adding reweight engine " << type);
switch (type) {
case kNEUT:
fAllRW[type] = new NEUTWeightEngine("neutrw");
break;
case kNUWRO:
fAllRW[type] = new NuWroWeightEngine("nuwrorw");
break;
case kGENIE:
fAllRW[type] = new GENIEWeightEngine("genierw");
break;
case kNORM:
fAllRW[type] = new SampleNormEngine("normrw");
break;
case kLIKEWEIGHT:
fAllRW[type] = new LikelihoodWeightEngine("likerw");
break;
case kT2K:
fAllRW[type] = new T2KWeightEngine("t2krw");
break;
case kCUSTOM:
fAllRW[type] = new NUISANCEWeightEngine("nuisrw");
break;
case kSPLINEPARAMETER:
fAllRW[type] = new SplineWeightEngine("splinerw");
break;
case kNIWG:
fAllRW[type] = new NIWGWeightEngine("niwgrw");
break;
case kOSCILLATION:
fAllRW[type] = new OscWeightEngine();
break;
case kMODENORM:
fAllRW[type] = new ModeNormEngine();
break;
#ifdef __NOVA_ENABLED__
case kNOvARWGT:
fAllRW[type] = new NOvARwgtEngine();
break;
#endif
+#ifdef __NUSYST_ENABLED__
+ case kNuSystematics:
+ fAllRW[type] = new nusystematicsWeightEngine();
+ break;
+#endif
default:
NUIS_ABORT("CANNOT ADD RW Engine for unknown dial type: " << type);
break;
}
}
WeightEngineBase *FitWeight::GetRWEngine(int type) {
if (HasRWEngine(type)) {
return fAllRW[type];
}
NUIS_ABORT("CANNOT get RW Engine for dial type: " << type);
}
bool FitWeight::HasRWEngine(int type) {
switch (type) {
case kNEUT:
case kNUWRO:
case kGENIE:
case kNORM:
case kLIKEWEIGHT:
case kT2K:
case kCUSTOM:
case kSPLINEPARAMETER:
case kNIWG:
case kOSCILLATION:
#ifdef __NOVA_ENABLED__
- case kNOvARWGT: {
+ case kNOvARWGT:
+#endif
+#ifdef __NUSYST_ENABLED__
+ case kNuSystematics:
+#endif
+
+ {
return fAllRW.count(type);
}
-#endif
default: { NUIS_ABORT("CANNOT get RW Engine for dial type: " << type); }
}
}
void FitWeight::IncludeDial(std::string name, std::string type, double val) {
// Should register the dial here.
int typeenum = Reweight::ConvDialType(type);
IncludeDial(name, typeenum, val);
}
void FitWeight::IncludeDial(std::string name, int dialtype, double val) {
// Get the dial enum
int nuisenum = Reweight::ConvDial(name, dialtype);
if (nuisenum == -1) {
NUIS_ERR(FTL, "Could not include dial " << name);
NUIS_ERR(FTL, "With dialtype: " << dialtype);
NUIS_ERR(FTL, "With value: " << val);
NUIS_ABORT("With nuisenum: " << nuisenum);
}
// Setup RW Engine Pointer
if (fAllRW.find(dialtype) == fAllRW.end()) {
AddRWEngine(dialtype);
}
WeightEngineBase *rw = fAllRW[dialtype];
// Include the dial
rw->IncludeDial(name, val);
// Set Dial Value
if (val != -9999.9) {
rw->SetDialValue(name, val);
}
// Sort Maps
fAllEnums[name] = nuisenum;
fAllValues[nuisenum] = val;
// Sort Lists
fNameList.push_back(name);
fEnumList.push_back(nuisenum);
fValueList.push_back(val);
}
void FitWeight::Reconfigure(bool silent) {
// Reconfigure all added RW engines
for (std::map::iterator iter = fAllRW.begin();
iter != fAllRW.end(); iter++) {
(*iter).second->Reconfigure(silent);
}
}
void FitWeight::SetDialValue(std::string name, double val) {
// Add extra check, if name not found look for one with name in it.
int nuisenum = fAllEnums[name];
SetDialValue(nuisenum, val);
}
// Allow for name aswell using GlobalList to determine sample name.
void FitWeight::SetDialValue(int nuisenum, double val) {
// Conv dial type
int dialtype = Reweight::GetDialType(nuisenum);
if (fAllRW.find(dialtype) == fAllRW.end()) {
NUIS_ERR(FTL, "Can't find RW engine for parameter " << fNameList[dialtype]);
NUIS_ERR(FTL, "With dialtype " << dialtype << ", "
- << Reweight::RemoveDialType(nuisenum));
+ << Reweight::RemoveDialType(nuisenum));
NUIS_ABORT("Are you sure you enabled the right engines?");
}
// Get RW Engine for this dial
fAllRW[dialtype]->SetDialValue(nuisenum, val);
fAllValues[nuisenum] = val;
// Update ValueList
for (size_t i = 0; i < fEnumList.size(); i++) {
if (fEnumList[i] == nuisenum) {
fValueList[i] = val;
}
}
}
void FitWeight::SetAllDials(const double *x, int n) {
for (size_t i = 0; i < (UInt_t)n; i++) {
int rwenum = fEnumList[i];
SetDialValue(rwenum, x[i]);
}
Reconfigure();
}
double FitWeight::GetDialValue(std::string name) {
// Add extra check, if name not found look for one with name in it.
int nuisenum = fAllEnums[name];
return GetDialValue(nuisenum);
}
double FitWeight::GetDialValue(int nuisenum) { return fAllValues[nuisenum]; }
int FitWeight::GetDialPos(std::string name) {
int rwenum = fAllEnums[name];
return GetDialPos(rwenum);
}
int FitWeight::GetDialPos(int nuisenum) {
for (size_t i = 0; i < fEnumList.size(); i++) {
if (fEnumList[i] == nuisenum) {
return i;
}
}
NUIS_ABORT("No Dial Found! (enum = " << nuisenum << ") ");
}
bool FitWeight::DialIncluded(std::string name) {
return (fAllEnums.find(name) != fAllEnums.end());
}
bool FitWeight::DialIncluded(int rwenum) {
return (fAllValues.find(rwenum) != fAllValues.end());
}
double FitWeight::CalcWeight(BaseFitEvt *evt) {
double rwweight = 1.0;
for (std::map::iterator iter = fAllRW.begin();
iter != fAllRW.end(); iter++) {
double w = (*iter).second->CalcWeight(evt);
rwweight *= w;
}
return rwweight;
}
void FitWeight::UpdateWeightEngine(const double *x) {
size_t count = 0;
for (std::vector::iterator iter = fEnumList.begin();
iter != fEnumList.end(); iter++) {
SetDialValue((*iter), x[count]);
count++;
}
}
void FitWeight::GetAllDials(double *x, int n) {
for (int i = 0; i < n; i++) {
x[i] = GetDialValue(fEnumList[i]);
}
}
// bool FitWeight::NeedsEventReWeight(const double* x) {
// bool haschange = false;
// size_t count = 0;
// // Compare old to new and decide if RW needed.
// for (std::vector::iterator iter = fEnumList.begin();
// iter != fEnumList.end(); iter++) {
// int nuisenum = (*iter);
// int type = (nuisenum / 1000) - (nuisenum % 1000);
// // Compare old to new
// double oldval = GetDialValue(nuisenum);
// double newval = x[count];
// if (oldval != newval) {
// if (fAllRW[type]->NeedsEventReWeight()) {
// haschange = true;
// }
// }
// count++;
// }
// return haschange;
// }
double FitWeight::GetSampleNorm(std::string name) {
if (name.empty())
return 1.0;
// Find norm dial
if (fAllEnums.find(name + "_norm") != fAllEnums.end()) {
if (fAllValues.find(fAllEnums[name + "_norm"]) != fAllValues.end()) {
return fAllValues[fAllEnums[name + "_norm"]];
} else {
return 1.0;
}
} else {
return 1.0;
}
}
void FitWeight::Print() {
NUIS_LOG(REC, "Fit Weight State: ");
for (size_t i = 0; i < fNameList.size(); i++) {
- NUIS_LOG(REC, " -> Par " << i << ". " << fNameList[i] << " " << fValueList[i]);
+ NUIS_LOG(REC,
+ " -> Par " << i << ". " << fNameList[i] << " " << fValueList[i]);
}
}
diff --git a/src/Reweight/WeightUtils.cxx b/src/Reweight/WeightUtils.cxx
index b381b80..8c33b86 100644
--- a/src/Reweight/WeightUtils.cxx
+++ b/src/Reweight/WeightUtils.cxx
@@ -1,595 +1,614 @@
#include "WeightUtils.h"
#include "FitLogger.h"
#ifndef __NO_REWEIGHT__
#ifdef __T2KREW_ENABLED__
#include "T2KGenieReWeight.h"
#include "T2KNIWGReWeight.h"
#include "T2KNIWGUtils.h"
#include "T2KNeutReWeight.h"
#include "T2KNeutUtils.h"
#include "T2KReWeight.h"
using namespace t2krew;
#endif
#ifdef __NIWG_ENABLED__
#include "NIWGReWeight.h"
#include "NIWGSyst.h"
#endif
#ifdef __NEUT_ENABLED__
#include "NReWeight.h"
#include "NSyst.h"
#endif
#ifdef __NUWRO_REWEIGHT_ENABLED__
#include "NuwroReWeight.h"
#include "NuwroSyst.h"
#endif
#ifdef __GENIE_ENABLED__
#ifdef GENIE_PRE_R3
#ifndef __NO_GENIE_REWEIGHT__
#include "ReWeight/GReWeight.h"
#include "ReWeight/GSyst.h"
#endif
#else
using namespace genie;
#ifndef __NO_GENIE_REWEIGHT__
#include "RwFramework/GReWeight.h"
#include "RwFramework/GSyst.h"
using namespace genie::rew;
#endif
#endif
#endif
#ifdef __NOVA_ENABLED__
#include "NOvARwgtEngine.h"
#endif
+#ifdef __NUSYST_ENABLED__
+#include "nusystematicsWeightEngine.h"
+#endif
+
#endif // end of no reweight
#include "GlobalDialList.h"
#include "ModeNormEngine.h"
#include "NUISANCESyst.h"
#include "OscWeightEngine.h"
//********************************************************************
TF1 FitBase::GetRWConvFunction(std::string const &type,
std::string const &name) {
//********************************************************************
std::string dialfunc = "x";
std::string parType = type;
double low = -10000.0;
double high = 10000.0;
if (parType.find("parameter") == std::string::npos)
parType += "_parameter";
std::string line;
std::ifstream card(
(GeneralUtils::GetTopLevelDir() + "/parameters/dial_conversion.card")
.c_str(),
std::ifstream::in);
while (std::getline(card >> std::ws, line, '\n')) {
std::vector inputlist = GeneralUtils::ParseToStr(line, " ");
// Check the line length
if (inputlist.size() < 4)
continue;
// Check whether this is a comment
if (inputlist[0].c_str()[0] == '#')
continue;
// Check whether this is the correct parameter type
if (inputlist[0].compare(parType) != 0)
continue;
// Check the parameter name
if (inputlist[1].compare(name) != 0)
continue;
// inputlist[2] should be the units... ignore for now
dialfunc = inputlist[3];
// High and low are optional, check whether they exist
if (inputlist.size() > 4)
low = GeneralUtils::StrToDbl(inputlist[4]);
if (inputlist.size() > 5)
high = GeneralUtils::StrToDbl(inputlist[5]);
}
TF1 convfunc = TF1((name + "_convfunc").c_str(), dialfunc.c_str(), low, high);
return convfunc;
}
//********************************************************************
std::string FitBase::GetRWUnits(std::string const &type,
std::string const &name) {
//********************************************************************
std::string unit = "sig.";
std::string parType = type;
if (parType.find("parameter") == std::string::npos) {
parType += "_parameter";
}
std::string line;
std::ifstream card(
(GeneralUtils::GetTopLevelDir() + "/parameters/dial_conversion.card")
.c_str(),
std::ifstream::in);
while (std::getline(card >> std::ws, line, '\n')) {
std::vector inputlist = GeneralUtils::ParseToStr(line, " ");
// Check the line length
if (inputlist.size() < 3)
continue;
// Check whether this is a comment
if (inputlist[0].c_str()[0] == '#')
continue;
// Check whether this is the correct parameter type
if (inputlist[0].compare(parType) != 0)
continue;
// Check the parameter name
if (inputlist[1].compare(name) != 0)
continue;
unit = inputlist[2];
break;
}
return unit;
}
//********************************************************************
double FitBase::RWAbsToSigma(std::string const &type, std::string const &name,
double val) {
//********************************************************************
TF1 f1 = GetRWConvFunction(type, name);
double conv_val = f1.GetX(val);
if (fabs(conv_val) < 1E-10)
conv_val = 0.0;
NUIS_LOG(FIT, "AbsToSigma(" << name << ") = " << val << " -> " << conv_val);
return conv_val;
}
//********************************************************************
double FitBase::RWSigmaToAbs(std::string const &type, std::string const &name,
double val) {
//********************************************************************
TF1 f1 = GetRWConvFunction(type, name);
double conv_val = f1.Eval(val);
return conv_val;
}
//********************************************************************
double FitBase::RWFracToSigma(std::string const &type, std::string const &name,
double val) {
//********************************************************************
TF1 f1 = GetRWConvFunction(type, name);
double conv_val = f1.GetX((val * f1.Eval(0.0)));
if (fabs(conv_val) < 1E-10)
conv_val = 0.0;
return conv_val;
}
//********************************************************************
double FitBase::RWSigmaToFrac(std::string const &type, std::string const &name,
double val) {
//********************************************************************
TF1 f1 = GetRWConvFunction(type, name);
double conv_val = f1.Eval(val) / f1.Eval(0.0);
return conv_val;
}
int FitBase::ConvDialType(std::string const &type) {
if (!type.compare("neut_parameter"))
return kNEUT;
else if (!type.compare("niwg_parameter"))
return kNIWG;
else if (!type.compare("nuwro_parameter"))
return kNUWRO;
else if (!type.compare("t2k_parameter"))
return kT2K;
else if (!type.compare("genie_parameter"))
return kGENIE;
else if (!type.compare("custom_parameter"))
return kCUSTOM;
else if (!type.compare("norm_parameter"))
return kNORM;
else if (!type.compare("likeweight_parameter"))
return kLIKEWEIGHT;
else if (!type.compare("spline_parameter"))
return kSPLINEPARAMETER;
else if (!type.compare("osc_parameter"))
return kOSCILLATION;
else if (!type.compare("modenorm_parameter"))
return kMODENORM;
else if (!type.compare("nova_parameter"))
return kNOvARWGT;
+ else if (!type.compare("nusyst_parameter"))
+ return kNuSystematics;
else
return kUNKNOWN;
}
std::string FitBase::ConvDialType(int type) {
switch (type) {
case kNEUT: {
return "neut_parameter";
}
case kNIWG: {
return "niwg_parameter";
}
case kNUWRO: {
return "nuwro_parameter";
}
case kT2K: {
return "t2k_parameter";
}
case kGENIE: {
return "genie_parameter";
}
case kNORM: {
return "norm_parameter";
}
case kCUSTOM: {
return "custom_parameter";
}
case kLIKEWEIGHT: {
return "likeweight_parameter";
}
case kSPLINEPARAMETER: {
return "spline_parameter";
}
case kOSCILLATION: {
return "osc_parameter";
}
case kMODENORM: {
return "modenorm_parameter";
}
case kNOvARWGT: {
return "nova_parameter";
}
+ case kNuSystematics: {
+ return "nusyst_parameter";
+ }
default:
return "unknown_parameter";
}
}
int FitBase::GetDialEnum(std::string const &type, std::string const &name) {
return FitBase::GetDialEnum(FitBase::ConvDialType(type), name);
}
int FitBase::GetDialEnum(int type, std::string const &name) {
int offset = type * 1000;
int this_enum = Reweight::kNoDialFound; // Not Found
NUIS_LOG(DEB, "Getting dial enum " << type << " " << name);
// Select Types
switch (type) {
// NEUT DIAL TYPE
case kNEUT: {
#if defined(__NEUT_ENABLED__) && !defined(__NO_REWEIGHT__)
int neut_enum = (int)neut::rew::NSyst::FromString(name);
if (neut_enum != 0) {
this_enum = neut_enum + offset;
}
#else
this_enum = Reweight::kNoTypeFound; // Not enabled
#endif
break;
}
// NIWG DIAL TYPE
case kNIWG: {
#if defined(__NIWG_ENABLED__) && !defined(__NO_REWEIGHT__)
int niwg_enum = (int)niwg::rew::NIWGSyst::FromString(name);
if (niwg_enum != 0) {
this_enum = niwg_enum + offset;
}
#else
this_enum = Reweight::kNoTypeFound;
#endif
break;
}
// NUWRO DIAL TYPE
case kNUWRO: {
#if defined(__NUWRO_REWEIGHT_ENABLED__) && !defined(__NO_REWEIGHT__)
int nuwro_enum = (int)nuwro::rew::NuwroSyst::FromString(name);
if (nuwro_enum > 0) {
this_enum = nuwro_enum + offset;
}
#else
this_enum = Reweight::kNoTypeFound;
#endif
}
// GENIE DIAL TYPE
case kGENIE: {
#if defined(__GENIE_ENABLED__) && !defined(__NO_REWEIGHT__)
int genie_enum = (int)genie::rew::GSyst::FromString(name);
if (genie_enum > 0) {
this_enum = genie_enum + offset;
}
#else
this_enum = Reweight::kNoTypeFound;
#endif
break;
}
case kCUSTOM: {
int custom_enum = 0; // PLACEHOLDER
this_enum = custom_enum + offset;
break;
}
// T2K DIAL TYPE
case kT2K: {
#if defined(__T2KREW_ENABLED__) && !defined(__NO_REWEIGHT__)
int t2k_enum = (int)t2krew::T2KSyst::FromString(name);
if (t2k_enum > 0) {
this_enum = t2k_enum + offset;
}
#else
this_enum = Reweight::kNoTypeFound;
#endif
break;
}
case kNORM: {
if (gNormEnums.find(name) == gNormEnums.end()) {
gNormEnums[name] = gNormEnums.size() + 1 + offset;
}
this_enum = gNormEnums[name];
break;
}
case kLIKEWEIGHT: {
if (gLikeWeightEnums.find(name) == gLikeWeightEnums.end()) {
gLikeWeightEnums[name] = gLikeWeightEnums.size() + 1 + offset;
}
this_enum = gLikeWeightEnums[name];
break;
}
case kSPLINEPARAMETER: {
if (gSplineParameterEnums.find(name) == gSplineParameterEnums.end()) {
gSplineParameterEnums[name] = gSplineParameterEnums.size() + 1 + offset;
}
this_enum = gSplineParameterEnums[name];
break;
}
case kOSCILLATION: {
#ifdef __PROB3PP_ENABLED__
int oscEnum = OscWeightEngine::SystEnumFromString(name);
if (oscEnum != 0) {
this_enum = oscEnum + offset;
}
#else
this_enum = Reweight::kNoTypeFound; // Not enabled
#endif
}
case kMODENORM: {
size_t us_pos = name.find_first_of('_');
std::string numstr = name.substr(us_pos + 1);
int mode_num = std::atoi(numstr.c_str());
NUIS_LOG(FTL, "Getting mode num " << mode_num);
if (!mode_num) {
NUIS_ABORT("Attempting to parse dial name: \""
- << name << "\" as a mode norm dial but failed.");
+ << name << "\" as a mode norm dial but failed.");
}
this_enum = 60 + mode_num + offset;
break;
}
}
// If Not Enabled
if (this_enum == Reweight::kNoTypeFound) {
- NUIS_ERR(FTL, "RW Engine not supported for " << FitBase::ConvDialType(type));
+ NUIS_ERR(FTL,
+ "RW Engine not supported for " << FitBase::ConvDialType(type));
NUIS_ABORT("Check dial " << name);
}
// If Not Found
if (this_enum == Reweight::kNoDialFound) {
NUIS_ABORT("Dial " << name << " not found.");
}
return this_enum;
}
int Reweight::ConvDialType(std::string const &type) {
return FitBase::ConvDialType(type);
}
std::string Reweight::ConvDialType(int type) {
return FitBase::ConvDialType(type);
}
int Reweight::GetDialType(int type) {
int t = (type / 1000);
- return t > kNOvARWGT ? Reweight::kNoDialFound : t;
+ return t > kNuSystematics ? Reweight::kNoDialFound : t;
}
int Reweight::RemoveDialType(int type) { return (type % 1000); }
int Reweight::NEUTEnumFromName(std::string const &name) {
#if defined(__NEUT_ENABLED__) && !defined(__NO_REWEIGHT__)
int neutenum = (int)neut::rew::NSyst::FromString(name);
return (neutenum > 0) ? neutenum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::NIWGEnumFromName(std::string const &name) {
#if defined(__NIWG_ENABLED__) && !defined(__NO_REWEIGHT__)
int niwgenum = (int)niwg::rew::NIWGSyst::FromString(name);
return (niwgenum != 0) ? niwgenum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::NUWROEnumFromName(std::string const &name) {
#if defined(__NUWRO_REWEIGHT_ENABLED__) && !defined(__NO_REWEIGHT__)
int nuwroenum = (int)nuwro::rew::NuwroSyst::FromString(name);
return (nuwroenum > 0) ? nuwroenum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::GENIEEnumFromName(std::string const &name) {
#if defined(__GENIE_ENABLED__) && !defined(__NO_REWEIGHT__)
int genieenum = (int)genie::rew::GSyst::FromString(name);
return (genieenum > 0) ? genieenum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::T2KEnumFromName(std::string const &name) {
#if defined(__T2KREW_ENABLED__) && !defined(__NO_REWEIGHT__)
int t2kenum = (int)t2krew::T2KSyst::FromString(name);
return (t2kenum > 0) ? t2kenum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::OscillationEnumFromName(std::string const &name) {
#ifdef __PROB3PP_ENABLED__
int oscEnum = OscWeightEngine::SystEnumFromString(name);
return (oscEnum > 0) ? oscEnum : Reweight::kNoDialFound;
#else
return Reweight::kGeneratorNotBuilt;
#endif
}
int Reweight::NUISANCEEnumFromName(std::string const &name, int type) {
int nuisenum = Reweight::DialList().EnumFromNameAndType(name, type);
return nuisenum;
}
int Reweight::CustomEnumFromName(std::string const &name) {
int custenum = Reweight::ConvertNUISANCEDial(name);
return custenum;
}
int Reweight::ConvDial(std::string const &name, std::string const &type,
bool exceptions) {
return Reweight::ConvDial(name, Reweight::ConvDialType(type), exceptions);
}
int Reweight::ConvDial(std::string const &fullname, int type, bool exceptions) {
std::string name =
GeneralUtils::ParseToStr(fullname, ",")[0]; // Only use first dial given
// Produce offset seperating each type.
int offset = type * 1000;
int genenum = Reweight::kNoDialFound;
switch (type) {
case kNEUT:
genenum = NEUTEnumFromName(name);
break;
case kNIWG:
genenum = NIWGEnumFromName(name);
break;
case kNUWRO:
genenum = NUWROEnumFromName(name);
break;
case kGENIE:
genenum = GENIEEnumFromName(name);
break;
case kT2K:
genenum = T2KEnumFromName(name);
break;
case kCUSTOM:
genenum = CustomEnumFromName(name);
break;
case kNORM:
case kLIKEWEIGHT:
case kSPLINEPARAMETER:
case kNEWSPLINE:
genenum = NUISANCEEnumFromName(name, type);
break;
case kOSCILLATION:
genenum = OscillationEnumFromName(name);
break;
case kMODENORM:
genenum = ModeNormEngine::SystEnumFromString(name);
break;
#ifdef __NOVA_ENABLED__
case kNOvARWGT:
genenum = NOvARwgtEngine::GetWeightGeneratorIndex(name);
break;
#endif
+#ifdef __NUSYST_ENABLED__
+ case kNuSystematics: {
+ // Super inefficient...
+ nusystematicsWeightEngine we;
+ genenum = we.ConvDial(name);
+ break;
+ }
+#endif
+
default:
genenum = Reweight::kNoTypeFound;
break;
}
// Throw if required.
if (exceptions) {
// If Not Enabled
if (genenum == Reweight::kGeneratorNotBuilt) {
NUIS_ERR(FTL,
- "RW Engine not supported for " << FitBase::ConvDialType(type));
+ "RW Engine not supported for " << FitBase::ConvDialType(type));
NUIS_ABORT("Check dial " << name);
}
// If no type enabled
if (genenum == Reweight::kNoTypeFound) {
NUIS_ABORT("Type mismatch inside ConvDialEnum");
}
// If Not Found
if (genenum == Reweight::kNoDialFound) {
NUIS_ABORT("Dial " << name << " not found.");
}
}
// Add offset if no issue
int nuisenum = genenum;
if ((genenum != Reweight::kGeneratorNotBuilt) &&
(genenum != Reweight::kNoTypeFound) &&
(genenum != Reweight::kNoDialFound)) {
nuisenum += offset;
}
// Now register dial
Reweight::DialList().RegisterDialEnum(name, type, nuisenum);
return nuisenum;
}
std::string Reweight::ConvDial(int nuisenum) {
for (size_t i = 0; i < Reweight::DialList().fAllDialEnums.size(); i++) {
if (Reweight::DialList().fAllDialEnums[i] == nuisenum) {
return Reweight::DialList().fAllDialNames[i];
}
}
NUIS_LOG(FIT, "Cannot find dial with enum = " << nuisenum);
return "";
}
diff --git a/src/Reweight/WeightUtils.h b/src/Reweight/WeightUtils.h
index 4af1a2d..1792016 100644
--- a/src/Reweight/WeightUtils.h
+++ b/src/Reweight/WeightUtils.h
@@ -1,64 +1,65 @@
#ifndef WEIGHTUTILS_H
#define WEIGHTUTILS_H
#include "FitEvent.h"
#include "TF1.h"
enum extra_reweight_types {
kOSCILLATION = kLast_generator_event_type,
kMODENORM,
- kNOvARWGT
+ kNOvARWGT,
+ kNuSystematics
};
namespace FitBase {
TF1 GetRWConvFunction(std::string const &type, std::string const &name);
std::string GetRWUnits(std::string const &type, std::string const &name);
double RWSigmaToFrac(std::string const &type, std::string const &name,
double val);
double RWSigmaToAbs(std::string const &type, std::string const &name,
double val);
double RWAbsToSigma(std::string const &type, std::string const &name,
double val);
double RWFracToSigma(std::string const &type, std::string const &name,
double val);
int ConvDialType(std::string const &type);
std::string ConvDialType(int type);
int GetDialEnum(std::string const &type, std::string const &name);
int GetDialEnum(int type, std::string const &name);
static std::map gNormEnums;
static std::map gLikeWeightEnums;
static std::map gSplineParameterEnums;
}
namespace Reweight {
int ConvDial(std::string const &name, std::string const &type,
bool exceptions = false);
int ConvDial(std::string const &name, int type, bool exceptions = false);
std::string ConvDial(int nuisenum);
int ConvDialType(std::string const &type);
std::string ConvDialType(int type);
int GetDialType(int type);
int RemoveDialType(int type);
int NEUTEnumFromName(std::string const &name);
int NIWGEnumFromName(std::string const &name);
int NUWROEnumFromName(std::string const &name);
int T2KEnumFromName(std::string const &name);
int GENIEEnumFromName(std::string const &name);
int CustomEnumFromName(std::string const &name);
int NUISANCEEnumFromName(std::string const &name, int type);
int OscillationEnumFromName(std::string const &name);
static const int kNoDialFound = -1;
static const int kNoTypeFound = -2;
static const int kGeneratorNotBuilt = -3;
}
#endif
diff --git a/src/Reweight/nusystWeightEngine.cxx b/src/Reweight/nusystematicsWeightEngine.cxx
similarity index 59%
rename from src/Reweight/nusystWeightEngine.cxx
rename to src/Reweight/nusystematicsWeightEngine.cxx
index d3c4b3c..415c9e1 100644
--- a/src/Reweight/nusystWeightEngine.cxx
+++ b/src/Reweight/nusystematicsWeightEngine.cxx
@@ -1,116 +1,117 @@
// 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 "nusystematicsWeightEngine.h"
#include
#include
-nusystWeightEngine::nusystWeightEngine() { Config(); }
+nusystematicsWeightEngine::nusystematicsWeightEngine() { Config(); }
-void nusystWeightEngine::Config() {
+void nusystematicsWeightEngine::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;
+ NUIS_ABORT(
+ "Instantiaged nusystematicsWeightEngine but without specifying a "
+ "DUNERwt element that leads the way to the configuration.");
}
std::string fhicl_name = DuneRwtParam.front().GetS("ConfigFHiCL");
DUNErwt.LoadConfiguration(fhicl_name);
}
-int nusystWeightEngine::ConvDial(std::string name) {
+int nusystematicsWeightEngine::ConvDial(std::string name) {
if (!DUNErwt.HaveHeader(name)) {
- THROW("nusystWeightEngine passed dial: "
- << name << " that it does not understand.");
+ NUIS_ABORT("nusystematicsWeightEngine passed dial: "
+ << name << " that it does not understand.");
}
return DUNErwt.GetHeaderId(name);
}
-void nusystWeightEngine::IncludeDial(std::string name, double startval) {
+void nusystematicsWeightEngine::IncludeDial(std::string name, double startval) {
EnabledParams.push_back({systtools::paramId_t(ConvDial(name)), startval});
}
-void nusystWeightEngine::SetDialValue(int nuisenum, double val) {
+void nusystematicsWeightEngine::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) {
+void nusystematicsWeightEngine::SetDialValue(std::string name, double val) {
if (!IsDialIncluded(name)) {
- THROW("nusystWeightEngine passed dial: " << name
- << " that is not enabled.");
+ NUIS_ABORT("nusystematicsWeightEngine 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) {
+bool nusystematicsWeightEngine::IsDialIncluded(std::string name) {
return IsDialIncluded(ConvDial(name));
}
-bool nusystWeightEngine::IsDialIncluded(int nuisenum) {
+bool nusystematicsWeightEngine::IsDialIncluded(int nuisenum) {
systtools::paramId_t DuneRwtEnum = (nuisenum % 1000);
return systtools::ContainterHasParam(EnabledParams, DuneRwtEnum);
}
-double nusystWeightEngine::GetDialValue(std::string name) {
+double nusystematicsWeightEngine::GetDialValue(std::string name) {
if (!IsDialIncluded(name)) {
- THROW("nusystWeightEngine passed dial: " << name
- << " that is not enabled.");
+ NUIS_ABORT("nusystematicsWeightEngine passed dial: "
+ << name << " that is not enabled.");
}
systtools::ParamValue &pval =
GetParamElementFromContainer(EnabledParams, ConvDial(name));
return pval.val;
}
-double nusystWeightEngine::GetDialValue(int nuisenum) {
+double nusystematicsWeightEngine::GetDialValue(int nuisenum) {
if (!IsDialIncluded(nuisenum)) {
- THROW("nusystWeightEngine passed dial: " << nuisenum
- << " that is not enabled.");
+ NUIS_ABORT("nusystematicsWeightEngine 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; };
+void nusystematicsWeightEngine::Reconfigure(bool silent) {
+ fHasChanged = false;
+};
-bool nusystWeightEngine::NeedsEventReWeight() {
+bool nusystematicsWeightEngine::NeedsEventReWeight() {
if (fHasChanged) {
return true;
}
return false;
}
-double nusystWeightEngine::CalcWeight(BaseFitEvt *evt) {
- return DUNErwt.GetEventWeightResponse(*evt->genie_record,
+double nusystematicsWeightEngine::CalcWeight(BaseFitEvt *evt) {
+ return DUNErwt.GetEventWeightResponse(*evt->genie_event->event, EnabledParams);
}
-void nusystWeightEngine::Print() {
- std::cout << "nusystWeightEngine: " << std::endl;
+void nusystematicsWeightEngine::Print() {
+ std::cout << "nusystematicsWeightEngine: " << std::endl;
}
diff --git a/src/Reweight/nusystWeightEngine.h b/src/Reweight/nusystematicsWeightEngine.h
similarity index 95%
rename from src/Reweight/nusystWeightEngine.h
rename to src/Reweight/nusystematicsWeightEngine.h
index ef20548..a5c8fe6 100644
--- a/src/Reweight/nusystWeightEngine.h
+++ b/src/Reweight/nusystematicsWeightEngine.h
@@ -1,64 +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 {
+class nusystematicsWeightEngine : public WeightEngineBase {
public:
- nusystWeightEngine();
+ nusystematicsWeightEngine();
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