diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ddc23f..22eaba6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,173 +1,173 @@ cmake_minimum_required (VERSION 2.6 FATAL_ERROR) project(ExternalDataFitter) enable_language(Fortran) set (ExtFit_VERSION_MAJOR 1) set (ExtFit_VERSION_MINOR 0) #The q+1'th letter of the alphabet set (ExtFit_VERSION_REVISION 0) set (ExtFit_VERSION_STRING "v${ExtFit_VERSION_MAJOR}r${ExtFit_VERSION_MINOR}") if(${ExtFit_VERSION_REVISION} STRGREATER "0") set (ExtFit_VERSION_STRING "${ExtFit_VERSION_STRING}p${ExtFit_VERSION_REVISION}") endif() set (VERBOSE TRUE) set (CMAKE_SKIP_BUILD_RPATH TRUE) if(NOT DEFINED NOTEST OR NOT NOTEST) enable_testing() endif() include(${CMAKE_SOURCE_DIR}/cmake/cmessage.cmake) if(NOT DEFINED USE_NEUT AND NOT DEFINED USE_NuWro AND NOT DEFINED USE_GENIE AND NOT DEFINED USE_T2K AND NOT DEFINED USE_NIWG AND NOT DEFINED USE_GiBUU AND NOT DEFINED USE_NUANCE) cmessage(FATAL_ERROR "No reweight engines requested. Configure with at least " "one of -DUSE_{NEUT,NuWro,GENIE,NIWG,T2K,GiBUU,NUANCE}.") else() cmessage(STATUS "Generator Input Support: NEUT:${USE_NEUT}, NuWro:${USE_NuWro}, GENIE:${USE_GENIE}, NIWG:${USE_NIWG}, GiBUU:${USE_GiBUU}, NUANCE:${USE_NUANCE}") endif() #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() cmessage(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"") if(CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE DEBUG) elseif(NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE DEBUG) endif() cmessage(STATUS "CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"") ################################################################################ # Check Dependencies ################################################################################ -############################ Reweight Engines ################################ -include(${CMAKE_SOURCE_DIR}/cmake/ReweightEnginesSetup.cmake) - ################################## ROOT ###################################### include(${CMAKE_SOURCE_DIR}/cmake/ROOTSetup.cmake) +############################ Reweight Engines ################################ +include(${CMAKE_SOURCE_DIR}/cmake/ReweightEnginesSetup.cmake) + ################################# Pythia6 #################################### include(${CMAKE_SOURCE_DIR}/cmake/pythia6Setup.cmake) ################################## COMPILER #################################### include(${CMAKE_SOURCE_DIR}/cmake/c++CompilerSetup.cmake) ################################################################################ ################################# gperftools ################################### include(${CMAKE_SOURCE_DIR}/cmake/gperfSetup.cmake) ################################### doxygen ################################### include(${CMAKE_SOURCE_DIR}/cmake/docsSetup.cmake) ################################################################################ if(DEFINED USE_EXP AND USE_EXP) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DINMEMORYEVENTCLASS") endif() if(DEFINED USE_GiBUU AND USE_GiBUU) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__GiBUU_ENABLED__") include(${CMAKE_SOURCE_DIR}/cmake/GiBUUSetup.cmake) endif() if(DEFINED USE_NUANCE AND USE_NUANCE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__NUANCE_ENABLED__") endif() ################################################################################ set(MINCODE Routines FCN) set(CORE MCStudies FitBase Splines Utils #Devel ) ############### # Allow compilation against single experiment folder # Add later.. ############## set(EXPERIMENTS ANL ArgoNeuT BEBC BNL FNAL GGM K2K MINERvA MiniBooNE T2K) set(EXP_INCLUDE_DIRECTORIES) foreach(edir ${EXPERIMENTS}) set(EXP_INCLUDE_DIRECTORIES ${EXP_INCLUDE_DIRECTORIES};${CMAKE_SOURCE_DIR}/src/${edir}) endforeach() cmessage(STATUS "Included experiments: ${EXP_INCLUDE_DIRECTORIES}") foreach(mdir ${MINCODE}) cmessage (STATUS "Configuring directory: src/${mdir}") add_subdirectory(src/${mdir}) endforeach() foreach(edir ${EXPERIMENTS}) cmessage (STATUS "Configuring directory: src/${edir}") add_subdirectory(src/${edir}) endforeach() foreach(cdir ${CORE}) cmessage (STATUS "Configuring directory: src/${cdir}") add_subdirectory(src/${cdir}) endforeach() cmessage(STATUS "Module targets: ${MODULETargets}") add_subdirectory(app) add_subdirectory(src/Tests) configure_file(cmake/setup.sh.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY) install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" DESTINATION ${CMAKE_INSTALL_PREFIX}) install(PROGRAMS "${PROJECT_SOURCE_DIR}/scripts/nuiscardgen" DESTINATION bin) diff --git a/cmake/GENIESetup.cmake b/cmake/GENIESetup.cmake index fc4a974..a31b42d 100644 --- a/cmake/GENIESetup.cmake +++ b/cmake/GENIESetup.cmake @@ -1,171 +1,147 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ # TODO # check system for libxml2 # check whether we need the includes # check if we can use a subset of the GENIE libraries ################################################################################ # Check Dependencies ################################################################################ ################################# GENIE ###################################### if(NOT DEFINED GENIE AND NOT DEFINED ENV{GENIE}) cmessage(FATAL_ERROR "Variable GENIE is not defined. " "The location of a pre-built GENIE install must be defined either as" " $ cmake -DGENIE=/path/to/GENIE or as and environment vairable" " $ export GENIE=/path/to/GENIE") endif() if(NOT DEFINED GENIE AND DEFINED ENV{GENIE}) set(GENIE $ENV{GENIE}) endif() execute_process (COMMAND genie-config --libs OUTPUT_VARIABLE GENIE_LD_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) - -execute_process (COMMAND genie-config - --libdir OUTPUT_VARIABLE GENIE_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(${GENIE_LIBDIR} MATCHES .*2_10_.*) - message(STATUS "Replacing \"ReinSeghal\" with \"ReinSehgal\" due to known bug with version 2.10 of genie-config.") - set(OLD_GENIE_LD_LFLAGS ${GENIE_LD_FLAGS}) - STRING(REPLACE "ReinSeghal" "ReinSehgal" GENIE_FIX_LD_FLAGS ${GENIE_LD_FLAGS}) - message(STATUS "${OLD_GENIE_LD_LFLAGS} => ${GENIE_FIX_LD_FLAGS}") - set(GENIE_LD_FLAGS ${GENIE_FIX_LD_FLAGS}) -endif() - - -set(GENIE_LD_FLAGS "${GENIE_LD_FLAGS} -lGReWeight ${GENIE_LD_FLAGS}") - - execute_process (COMMAND genie-config --topsrcdir OUTPUT_VARIABLE GENIE_INCLUDES OUTPUT_STRIP_TRAILING_WHITESPACE) ################################ LHAPDF ###################################### if(NOT DEFINED LHAPDF_LIB AND NOT DEFINED ENV{LHAPDF_LIB}) cmessage(FATAL_ERROR "Variable LHAPDF_LIB is not defined. " "The location of a pre-built lhapdf install must be defined either as" " $ cmake -DLHAPDF_LIB=/path/to/LHAPDF_libraries or as and environment vairable" " $ export LHAPDF_LIB=/path/to/LHAPDF_libraries") endif() if(NOT DEFINED LHAPDF_LIB AND DEFINED ENV{LHAPDF_LIB}) set(LHAPDF_LIB $ENV{LHAPDF_LIB}) endif() if(NOT DEFINED LHAPDF_INC AND NOT DEFINED ENV{LHAPDF_INC}) cmessage(FATAL_ERROR "Variable LHAPDF_INC is not defined. " "The location of a pre-built lhapdf install must be defined either as" " $ cmake -DLHAPDF_INC=/path/to/LHAPDF_includes or as and environment vairable" " $ export LHAPDF_INC=/path/to/LHAPDF_includes") endif() -if(NOT DEFINED LHAPATH AND NOT DEFINED ENV{LHAPATH}) - - cmessage(FATAL_ERROR "Variable LHAPATH is not defined. " - "This is ") -elseif(DEFINED ENV{LHAPATH}) - set(LHAPATH $ENV{LHAPATH}) -endif() - if(NOT DEFINED LHAPDF_INC AND DEFINED ENV{LHAPDF_INC}) set(LHAPDF_INC $ENV{LHAPDF_INC}) endif() ################################ LIBXML ###################################### if(NOT DEFINED LIBXML2_LIB AND NOT DEFINED ENV{LIBXML2_LIB}) cmessage(FATAL_ERROR "Variable LIBXML2_LIB is not defined. " "The location of a pre-built libxml2 install must be defined either as" " $ cmake -DLIBXML2_LIB=/path/to/LIBXML2_libraries or as and environment vairable" " $ export LIBXML2_LIB=/path/to/LIBXML2_libraries") endif() if(NOT DEFINED LIBXML2_LIB AND DEFINED ENV{LIBXML2_LIB}) set(LIBXML2_LIB $ENV{LIBXML2_LIB}) endif() if(NOT DEFINED LIBXML2_INC AND NOT DEFINED ENV{LIBXML2_INC}) cmessage(FATAL_ERROR "Variable LIBXML2_INC is not defined. " "The location of a pre-built libxml2 install must be defined either as" " $ cmake -DLIBXML2_INC=/path/to/LIBXML2_includes or as and environment vairable" " $ export LIBXML2_INC=/path/to/LIBXML2_includes") endif() if(NOT DEFINED LIBXML2_INC AND DEFINED ENV{LIBXML2_INC}) set(LIBXML2_INC $ENV{LIBXML2_INC}) endif() ############################### log4cpp ###################################### if(NOT DEFINED LOG4CPP_LIB AND NOT DEFINED ENV{LOG4CPP_LIB}) cmessage(FATAL_ERROR "Variable LOG4CPP_LIB is not defined. " "The location of a pre-built log4cpp install must be defined either as" " $ cmake -DLOG4CPP_LIB=/path/to/LOG4CPP_libraries or as and environment vairable" " $ export LOG4CPP_LIB=/path/to/LOG4CPP_libraries") endif() if(NOT DEFINED LOG4CPP_LIB AND DEFINED ENV{LOG4CPP_LIB}) set(LOG4CPP_LIB $ENV{LOG4CPP_LIB}) endif() if(NOT DEFINED LOG4CPP_INC AND NOT DEFINED ENV{LOG4CPP_INC}) cmessage(FATAL_ERROR "Variable LOG4CPP_INC is not defined. " "The location of a pre-built log4cpp install must be defined either as" " $ cmake -DLOG4CPP_INC=/path/to/LOG4CPP_includes or as and environment vairable" " $ export LOG4CPP_INC=/path/to/LOG4CPP_includes") endif() if(NOT DEFINED LOG4CPP_INC AND DEFINED ENV{LOG4CPP_INC}) set(LOG4CPP_INC $ENV{LOG4CPP_INC}) endif() ################################################################################ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__GENIE_ENABLED__ ") set(RWENGINE_INCLUDE_DIRECTORIES ${RWENGINE_INCLUDE_DIRECTORIES} ${GENIE_INCLUDES} ${GENIE_INCLUDES}/GHEP ${GENIE_INCLUDES}/Ntuple ${GENIE_INCLUDES}/ReWeight ${LHAPDF_INC} ${LIBXML2_INC} ${LOG4CPP_INC}) set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} ${GENIE_LD_FLAGS} -L${LHAPDF_LIB} -lLHAPDF -L${LIBXML2_LIB} -lxml2 -L${LOG4CPP_LIB} -llog4cpp") set(NEED_PYTHIA6 TRUE) set(NEED_ROOTPYTHIA6 TRUE) - +set(NEED_ROOTEVEGEN TRUE) diff --git a/cmake/NuWroSetup.cmake b/cmake/NuWroSetup.cmake index d4107ba..d3be683 100644 --- a/cmake/NuWroSetup.cmake +++ b/cmake/NuWroSetup.cmake @@ -1,53 +1,89 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ -if(NOT DEFINED ENV{NUWRO}) +if(DEFINED BUILD_NuWro_FROM_FILE) - cmessage(FATAL_ERROR "Environment variable NUWRO is not defined. " - "This must be set to point to a prebuilt NuWro instance.") - -endif() + if(NOT EXISTS ${BUILD_NuWro_FROM_FILE}) + cmessage(FATAL_ERROR "Expected -DBUILD_NuWro_FROM_FILE to point to a valid input file. Cannot find: '${BUILD_NuWro_FROM_FILE}'") + endif() -set(NUWRO $ENV{NUWRO}) + if(CMAKE_BUILD_TYPE MATCHES DEBUG) + BuildROOTProject(NuWro_event1 ${BUILD_NuWro_FROM_FILE} "event,vec,vect,particle,flags,params,line" STATIC) + SET(ROOTLIBNAME "libNuWro_event1.a") + else(CMAKE_BUILD_TYPE MATCHES RELEASE) + BuildROOTProject(NuWro_event1 ${BUILD_NuWro_FROM_FILE} "event,vec,vect,particle,flags,params,line" SHARED) + SET(ROOTLIBNAME "libNuWro_event1.so") + endif() -# If you are using a version of NuWro without reweighting use this to compile. -if(DEFINED NO_NuWro_RW AND NO_NuWro_RW) + ADD_CUSTOM_TARGET(NuWro_event1HeaderLink ALL + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_BINARY_DIR}/NuWro_event1/event.h + ${CMAKE_BINARY_DIR}/NuWro_event1/event1.h + DEPENDS NuWro_event1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__NUWRO_ENABLED__ ") - set(RWENGINE_INCLUDE_DIRECTORIES ${NUWRO}/src) + LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/NuWro_event1) - set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} ${NUWRO}/bin/event1.so") + set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/${ROOTLIBNAME}") + LIST(APPEND PROJECTWIDE_EXTRA_DEPENDENCIES NuWro_event1HeaderLink) + + install(TARGETS NuWro_event1 DESTINATION lib) + + SET(NUWRO_BUILT_FROM_FILE 1) else() + SET(NUWRO_BUILT_FROM_FILE 0) + + if(NOT DEFINED ENV{NUWRO}) + + cmessage(FATAL_ERROR "Environment variable NUWRO is not defined. " + "This must be set to point to a prebuilt NuWro instance.") - if(DEFINED USE_EXP AND USE_EXP) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNW_READHISTFROMINP") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__NUWRO_ENABLED__ -D__NUWRO_REWEIGHT_ENABLED__ ") + set(NUWRO $ENV{NUWRO}) - set(RWENGINE_INCLUDE_DIRECTORIES ${RWENGINE_INCLUDE_DIRECTORIES} ${NUWRO}/src ${NUWRO}/src/reweight ${NUWRO}/build/src) +# If you are using a version of NuWro without reweighting use this to compile. + if(DEFINED NO_NuWro_RW AND NO_NuWro_RW) - set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} -L${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib -lreweight -levent") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__NUWRO_ENABLED__ ") + + LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUWRO}/src) + + set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} ${NUWRO}/bin/event1.so") + + else() + + if(DEFINED USE_EXP AND USE_EXP) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNW_READHISTFROMINP") + endif() + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__NUWRO_ENABLED__ -D__NUWRO_REWEIGHT_ENABLED__ ") + + LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUWRO}/src ${NUWRO}/src/reweight ${NUWRO}/build/src) + + set(RWENGINE_LINKER_FLAGS "${RWENGINE_LINKER_FLAGS} -L${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib -lreweight -levent") + + endif() + set(NEED_PYTHIA6 TRUE) + set(NEED_ROOTPYTHIA6 TRUE) endif() -set(NEED_PYTHIA6 TRUE) -set(NEED_ROOTPYTHIA6 TRUE) diff --git a/cmake/ROOTSetup.cmake b/cmake/ROOTSetup.cmake index a4cbec2..e467c17 100644 --- a/cmake/ROOTSetup.cmake +++ b/cmake/ROOTSetup.cmake @@ -1,68 +1,129 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ if ( NOT DEFINED ENV{ROOTSYS} ) cmessage (FATAL_ERROR "$ROOTSYS is not defined, please set up root first.") else() cmessage(STATUS "Using ROOT installed at $ENV{ROOTSYS}") set(CMAKE_ROOTSYS $ENV{ROOTSYS}) endif() execute_process (COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND root-config --libdir OUTPUT_VARIABLE ROOT_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND root-config --features OUTPUT_VARIABLE ROOT_FEATURES OUTPUT_STRIP_TRAILING_WHITESPACE) set(ROOT_LD_FLAGS "-L${ROOT_LIBDIR}") set(ROOT_LIBS Core;Cint;RIO;Net;Hist;Graf;Graf3d;Gpad;Tree;Rint;Postscript;Matrix;Physics;MathCore;Thread;EG;Geom;GenVector) -if(USE_GENIE) - cmessage(STATUS "GENIE requires eve generation libraries") - set(ROOT_LIBS Eve;EG;TreePlayer;Geom;Ged;Gui;${ROOT_LIBS}) -endif() - if(NOT DEFINED USE_MINIMIZER) if("${ROOT_FEATURES}" MATCHES "minuit2") cmessage(STATUS "ROOT built with MINUIT2 support") set(USE_MINIMIZER 1) else() cmessage(STATUS "ROOT built without MINUIT2 support, minimizer functionality will be disabled.") set(USE_MINIMIZER 0) endif() endif() if("${ROOT_FEATURES}" MATCHES "opengl") cmessage(STATUS "ROOT built with OpenGL support") set(ROOT_LIBS ${ROOT_LIBS};RGL) endif() -if(DEFINED NEED_ROOTPYTHIA6 AND NEED_ROOTPYTHIA6) - set(ROOT_LIBS ${ROOT_LIBS};EGPythia6;Pythia6) -endif() - cmessage ( STATUS "[ROOT]: root-config --version: " ${ROOT_VERSION}) cmessage ( STATUS "[ROOT]: root-config --cflags: " ${ROOT_CXX_FLAGS} ) cmessage ( STATUS "[ROOT]: root-config --libs: " ${ROOT_LD_FLAGS} ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}") + + +#Helper functions for building dictionaries +function(GenROOTDictionary OutputDictName Header LinkDef) + + get_directory_property(incdirs INCLUDE_DIRECTORIES) + string(REPLACE ";" ";-I" LISTDIRINCLUDES "-I${incdirs}") + string(REPLACE " " ";" LISTCPPFLAGS "${CMAKE_CXX_FLAGS}") + + #ROOT5 CINT cannot handle it. + list(REMOVE_ITEM LISTCPPFLAGS "-std=c++11") + + message(STATUS "LISTCPPFLAGS: ${LISTCPPFLAGS}") + message(STATUS "LISTINCLUDES: ${LISTDIRINCLUDES}") + #Learn how to generate the Dict.cxx and Dict.hxx + add_custom_command( + OUTPUT "${OutputDictName}.cxx" "${OutputDictName}.h" + COMMAND rootcint + ARGS -f ${OutputDictName}.cxx -c + -p ${LISTDIRINCLUDES} ${LISTCPPFLAGS} ${Header} ${LinkDef} + DEPENDS ${Header};${LinkDef}) +endfunction() + + +function(BuildROOTProject ProjectName InputFile CommaSeparatedClassesToDump LIBLINKMODE) + + string(REPLACE "," ";" HeadersToDump ${CommaSeparatedClassesToDump}) + set(OUTPUTFILES ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectSource.cxx + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}LinkDef.h + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectHeaders.h + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectInstances.h) + + cmessage(STATUS "As part of ROOT project: ${ProjectName}") + foreach (header ${HeadersToDump}) + LIST(APPEND OUTPUTFILES "${CMAKE_BINARY_DIR}/${ProjectName}/${header}.h") + cmessage(STATUS "Will generate: ${CMAKE_BINARY_DIR}/${ProjectName}/${header}.h") + endforeach() + + add_custom_command( + OUTPUT ${OUTPUTFILES} + COMMAND ${CMAKE_BINARY_DIR}/src/Utils/DumpROOTClassesFromVector + ARGS ${InputFile} + ${CMAKE_BINARY_DIR}/${ProjectName} + ${CommaSeparatedClassesToDump} + VERBATIM + DEPENDS DumpROOTClassesFromVector) + + add_custom_target(${ProjectName}_sources + DEPENDS ${OUTPUTFILES}) + + GenROOTDictionary( + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectHeaders.h + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}LinkDef.h + ) + + add_custom_target(${ProjectName}ProjectDict + DEPENDS + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict.cxx + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict.h ) + # add_dependencies(${ProjectName}ProjectDict ${ProjectName}_sources) + + #ProjectSource.cxx includes ProjectDict.cxx, so no need to add to compilation. + set(ROAA_SOURCEFILES + ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectSource.cxx) + + add_library(${ProjectName} ${LIBLINKMODE} ${ROAA_SOURCEFILES}) + add_dependencies(${ProjectName} ${ProjectName}ProjectDict) + +endfunction() diff --git a/cmake/ReweightEnginesSetup.cmake b/cmake/ReweightEnginesSetup.cmake index 5b42950..a36bcb3 100644 --- a/cmake/ReweightEnginesSetup.cmake +++ b/cmake/ReweightEnginesSetup.cmake @@ -1,58 +1,67 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(RWENGINE_INCLUDE_DIRECTORIES "") ################################## NEUT ###################################### if(DEFINED USE_NEUT AND USE_NEUT) include(${CMAKE_SOURCE_DIR}/cmake/NEUTSetup.cmake) cmessage(STATUS "Using NEUT Reweight engine.") else() set(USE_NEUT 0) endif() ################################# NuWro ###################################### if(DEFINED USE_NuWro AND USE_NuWro) include(${CMAKE_SOURCE_DIR}/cmake/NuWroSetup.cmake) cmessage(STATUS "Using NuWro Reweight engine.") else() set(USE_NuWro 0) endif() ################################## GENIE ##################################### if(DEFINED USE_GENIE AND USE_GENIE) include(${CMAKE_SOURCE_DIR}/cmake/GENIESetup.cmake) cmessage(STATUS "Using GENIE Reweight engine.") else() set(USE_GENIE 0) endif() ################################## NIWG ###################################### if(DEFINED USE_NIWG AND USE_NIWG) include(${CMAKE_SOURCE_DIR}/cmake/NIWGSetup.cmake) cmessage(STATUS "Using NIWG Reweight engine.") else() set(USE_NIWG 0) endif() ################################## T2K ###################################### if(DEFINED USE_T2K AND USE_T2K) include(${CMAKE_SOURCE_DIR}/cmake/T2KSetup.cmake) cmessage(STATUS "Using T2K Reweight engine.") else() set(USE_T2K 0) endif() cmessage(STATUS "Reweight engine include directories: ${RWENGINE_INCLUDE_DIRECTORIES}") + +if(DEFINED NEED_ROOTEVEGEN AND NEED_ROOTEVEGEN) + cmessage(STATUS "Require ROOT eve generation libraries") + set(ROOT_LIBS Eve;EG;TreePlayer;Geom;Ged;Gui;${ROOT_LIBS}) +endif() +if(DEFINED NEED_ROOTPYTHIA6 AND NEED_ROOTPYTHIA6) + cmessage(STATUS "Require ROOT Pythia6 libraries") + set(ROOT_LIBS ${ROOT_LIBS};EGPythia6;Pythia6) +endif() diff --git a/src/ANL/CMakeLists.txt b/src/ANL/CMakeLists.txt index 3c3aab5..bc394ea 100644 --- a/src/ANL/CMakeLists.txt +++ b/src/ANL/CMakeLists.txt @@ -1,133 +1,134 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES ANL_CCQE_Evt_1DQ2_nu.cxx ANL_CCQE_XSec_1DEnu_nu.cxx ANL_CC1npip_Evt_1DcosmuStar_nu.cxx ANL_CC1npip_Evt_1Dppi_nu.cxx ANL_CC1npip_Evt_1DQ2_nu.cxx ANL_CC1npip_XSec_1DEnu_nu.cxx ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx ANL_CC1pi0_Evt_1DQ2_nu.cxx ANL_CC1pi0_XSec_1DEnu_nu.cxx ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx ANL_CC1ppip_Evt_1Dppi_nu.cxx ANL_CC1ppip_Evt_1DQ2_nu.cxx ANL_CC1ppip_Evt_1Dthpr_nu.cxx ANL_CC1ppip_XSec_1DEnu_nu.cxx ANL_CC1ppip_XSec_1DQ2_nu.cxx ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx ANL_CC1ppip_Evt_1Dphi_nu.cxx ANL_NC1npip_Evt_1Dppi_nu.cxx ANL_NC1ppim_XSec_1DEnu_nu.cxx ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx ) set(HEADERFILES ANL_CCQE_Evt_1DQ2_nu.h ANL_CCQE_XSec_1DEnu_nu.h ANL_CC1npip_Evt_1DcosmuStar_nu.h ANL_CC1npip_Evt_1Dppi_nu.h ANL_CC1npip_Evt_1DQ2_nu.h ANL_CC1npip_XSec_1DEnu_nu.h ANL_CC1pi0_Evt_1DcosmuStar_nu.h ANL_CC1pi0_Evt_1DQ2_nu.h ANL_CC1pi0_XSec_1DEnu_nu.h ANL_CC1ppip_Evt_1DcosmuStar_nu.h ANL_CC1ppip_Evt_1Dppi_nu.h ANL_CC1ppip_Evt_1DQ2_nu.h ANL_CC1ppip_Evt_1Dthpr_nu.h ANL_CC1ppip_XSec_1DEnu_nu.h ANL_CC1ppip_XSec_1DQ2_nu.h ANL_CC1ppip_Evt_1DcosthAdler_nu.h ANL_CC1ppip_Evt_1Dphi_nu.h ANL_NC1npip_Evt_1Dppi_nu.h ANL_NC1ppim_XSec_1DEnu_nu.h ANL_NC1ppim_Evt_1DcosmuStar_nu.h ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h ) set(LIBNAME expANL) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/ArgoNeuT/CMakeLists.txt b/src/ArgoNeuT/CMakeLists.txt index 8a78d0f..432b1d0 100644 --- a/src/ArgoNeuT/CMakeLists.txt +++ b/src/ArgoNeuT/CMakeLists.txt @@ -1,55 +1,56 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx ) set(HEADERFILES ArgoNeuT_CCInc_XSec_1Dpmu_antinu.h ArgoNeuT_CCInc_XSec_1Dpmu_nu.h ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h ) set(LIBNAME expArgoNeuT) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/BEBC/CMakeLists.txt b/src/BEBC/CMakeLists.txt index 4fa2da9..1c9721e 100644 --- a/src/BEBC/CMakeLists.txt +++ b/src/BEBC/CMakeLists.txt @@ -1,69 +1,70 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES BEBC_CC1npim_XSec_1DEnu_antinu.cxx BEBC_CC1npim_XSec_1DQ2_antinu.cxx BEBC_CC1npip_XSec_1DEnu_nu.cxx BEBC_CC1npip_XSec_1DQ2_nu.cxx BEBC_CC1pi0_XSec_1DEnu_nu.cxx BEBC_CC1pi0_XSec_1DQ2_nu.cxx BEBC_CC1ppim_XSec_1DEnu_antinu.cxx BEBC_CC1ppim_XSec_1DQ2_antinu.cxx BEBC_CC1ppip_XSec_1DEnu_nu.cxx BEBC_CC1ppip_XSec_1DQ2_nu.cxx BEBC_CCQE_XSec_1DQ2_nu.cxx ) set(HEADERFILES BEBC_CC1npim_XSec_1DEnu_antinu.h BEBC_CC1npim_XSec_1DQ2_antinu.h BEBC_CC1npip_XSec_1DEnu_nu.h BEBC_CC1npip_XSec_1DQ2_nu.h BEBC_CC1pi0_XSec_1DEnu_nu.h BEBC_CC1pi0_XSec_1DQ2_nu.h BEBC_CC1ppim_XSec_1DEnu_antinu.h BEBC_CC1ppim_XSec_1DQ2_antinu.h BEBC_CC1ppip_XSec_1DEnu_nu.h BEBC_CC1ppip_XSec_1DQ2_nu.h BEBC_CCQE_XSec_1DQ2_nu.h ) set(LIBNAME expBEBC) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/BNL/CMakeLists.txt b/src/BNL/CMakeLists.txt index 02015c2..6288677 100644 --- a/src/BNL/CMakeLists.txt +++ b/src/BNL/CMakeLists.txt @@ -1,67 +1,68 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES BNL_CC1npip_Evt_1DQ2_nu.cxx BNL_CC1npip_XSec_1DEnu_nu.cxx BNL_CC1pi0_Evt_1DQ2_nu.cxx BNL_CC1pi0_XSec_1DEnu_nu.cxx BNL_CC1ppip_Evt_1DQ2_nu.cxx BNL_CC1ppip_XSec_1DEnu_nu.cxx BNL_CCQE_Evt_1DQ2_nu.cxx BNL_CCQE_XSec_1DEnu_nu.cxx BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx BNL_CC1ppip_Evt_1Dphi_nu.cxx ) set(HEADERFILES BNL_CC1npip_Evt_1DQ2_nu.h BNL_CC1npip_XSec_1DEnu_nu.h BNL_CC1pi0_Evt_1DQ2_nu.h BNL_CC1pi0_XSec_1DEnu_nu.h BNL_CC1ppip_Evt_1DQ2_nu.h BNL_CC1ppip_XSec_1DEnu_nu.h BNL_CCQE_Evt_1DQ2_nu.h BNL_CCQE_XSec_1DEnu_nu.h BNL_CC1ppip_Evt_1DcosthAdler_nu.h BNL_CC1ppip_Evt_1Dphi_nu.h ) set(LIBNAME expBNL) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FCN/CMakeLists.txt b/src/FCN/CMakeLists.txt index ba6ec1b..7aa44b5 100644 --- a/src/FCN/CMakeLists.txt +++ b/src/FCN/CMakeLists.txt @@ -1,65 +1,65 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES JointFCN.cxx SampleList.cxx ) set(HEADERFILES JointFCN.h MinimizerFCN.h SampleList.h ) set(LIBNAME FCN) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${EXP_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/ANL) include_directories(${CMAKE_SOURCE_DIR}/src/BNL) include_directories(${CMAKE_SOURCE_DIR}/src/FNAL) include_directories(${CMAKE_SOURCE_DIR}/src/GGM) include_directories(${CMAKE_SOURCE_DIR}/src/MINERvA) include_directories(${CMAKE_SOURCE_DIR}/src/MiniBooNE) include_directories(${CMAKE_SOURCE_DIR}/src/T2K) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) include_directories(${CMAKE_SOURCE_DIR}/src/FCN) - 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FNAL/CMakeLists.txt b/src/FNAL/CMakeLists.txt index dc7d444..2ceaad8 100644 --- a/src/FNAL/CMakeLists.txt +++ b/src/FNAL/CMakeLists.txt @@ -1,56 +1,57 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES FNAL_CC1ppip_Evt_1DQ2_nu.cxx FNAL_CC1ppip_XSec_1DEnu_nu.cxx FNAL_CC1ppip_XSec_1DQ2_nu.cxx FNAL_CCQE_Evt_1DQ2_nu.cxx ) set(HEADERFILES FNAL_CC1ppim_XSec_1DEnu_antinu.h FNAL_CC1ppip_Evt_1DQ2_nu.h FNAL_CC1ppip_XSec_1DEnu_nu.h FNAL_CC1ppip_XSec_1DQ2_nu.h FNAL_CCQE_Evt_1DQ2_nu.h ) set(LIBNAME expFNAL) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FitBase/CMakeLists.txt b/src/FitBase/CMakeLists.txt index f5ed6b6..123e33b 100644 --- a/src/FitBase/CMakeLists.txt +++ b/src/FitBase/CMakeLists.txt @@ -1,68 +1,69 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES ParamPull.cxx BaseFitEvt.cxx FitParticle.cxx FitWeight.cxx Measurement1D.cxx EventManager.cxx InputHandler.cxx Measurement2D.cxx FitEvent.cxx JointMeas1D.cxx MeasurementBase.cxx GeneratorUtils.cxx StdHepEvt.cxx TemplateMeas1D.cxx InputUtils.cxx ) set(HEADERFILES ParamPull.h NuanceEvent.h BaseFitEvt.h FitEvent.h JointMeas1D.h Measurement2D.h EventManager.h FitParticle.h FitWeight.h MeasurementBase.h InputHandler.h Measurement1D.h GeneratorUtils.h StdHepEvt.h TemplateMeas1D.h InputUtils.h ) set(LIBNAME FitBase) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FitBase/FitEvent.cxx b/src/FitBase/FitEvent.cxx index c4eafb3..0edf835 100644 --- a/src/FitBase/FitEvent.cxx +++ b/src/FitBase/FitEvent.cxx @@ -1,885 +1,885 @@ // 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 <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FitEvent.h" #include <iostream> #include "TObjArray.h" #ifdef __GENIE_ENABLED__ #include "Conventions/Units.h" #endif //*************************************************** // Refill all the particle vectors etc for the event void FitEvent::CalcKinematics() { //*************************************************** // HELLO SUBLIME #ifdef __NEUT_ENABLED__ if (fType == kNEUT) NeutKinematics(); #endif #ifdef __NUWRO_ENABLED__ if (fType == kNUWRO) NuwroKinematics(); #endif #ifdef __GENIE_ENABLED__ if (fType == kGENIE) GENIEKinematics(); #endif #ifdef __NUANCE_ENABLED__ if (fType == kNUANCE) NuanceKinematics(); #endif #ifdef __GiBUU_ENABLED__ if (fType == kGiBUU) GiBUUKinematics(); #endif return; }; //*************************************************** void FitEvent::ResetEvent() { //*************************************************** // Sort Event Info fMode = 9999; Mode = 9999; fEventNo = -1; fTotCrs = -1.0; fTargetA = -1; fTargetZ = -1; fTargetH = -1; fBound = false; fNParticles = 0; for (unsigned int i = 0; i < kMaxParticles; i++) { FitParticle* fp = fParticleList[i]; if (fp) delete fp; fParticleList[i] = NULL; } } // NEUT GENERATOR SPECIFIC #ifdef __NEUT_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NeutVect** tempevent) { //*************************************************** fType = kNEUT; fNeutVect = *tempevent; } //*************************************************** void FitEvent::NeutKinematics() { //*************************************************** ResetEvent(); // Get Event Info fMode = fNeutVect->Mode; Mode = fNeutVect->Mode; fEventNo = fNeutVect->EventNo; fTotCrs = fNeutVect->Totcrs; fTargetA = fNeutVect->TargetA; fTargetZ = fNeutVect->TargetZ; fTargetH = fNeutVect->TargetH; fBound = bool(fNeutVect->Ibound); // Check Particle Stack UInt_t npart = fNeutVect->Npart(); if (npart > kMaxParticles) { ERR(FTL) << "NEUT has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Particle Stack fNParticles = 0; for (UInt_t i = 0; i < npart; i++) { NeutPart* part = fNeutVect->PartInfo(i); // State int state = kUndefinedState; // fStatus == -1 means initial state if (part->fIsAlive == false && part->fStatus == -1) { state = kInitialState; // NEUT has a bit of a strange convention for fIsAlive and fStatus // combinations // for NC and neutrino particle isAlive true/false and status 2 means // final state particle // for other particles in NC status 2 means it's an FSI particle // for CC it means it was an FSI particle } else if (part->fStatus == 2) { // NC case is a little strange... The outgoing neutrino might be alive or // not alive. Remaining particles with status 2 are FSI particles that // reinteracted if (abs(fNeutVect->Mode) > 30 && (abs(part->fPID) == 14 || abs(part->fPID) == 12)) { state = kFinalState; // The usual CC case } else if (part->fIsAlive == true) { state = kFSIState; } } else if (part->fIsAlive == true && part->fStatus == 2 && (abs(part->fPID) == 14 || abs(part->fPID) == 12)) { state = kFinalState; } else if (part->fIsAlive == true && part->fStatus == 0) { state = kFinalState; } else if (part->fIsAlive == true) { ERR(WRN) << "Undefined NEUT state " << " Alive: " << part->fIsAlive << " Status: " << part->fStatus << " PDG: " << part->fPID << std::endl; throw; } // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = part->fP.X(); fParticleMom[fNParticles][1] = part->fP.Y(); fParticleMom[fNParticles][2] = part->fP.Z(); fParticleMom[fNParticles][3] = part->fP.T(); // PDG fParticlePDG[fNParticles] = part->fPID; fNParticles++; } OrderStack(); return; }; #endif // NUWRO GENERATOR SPECIFIC #ifdef __NUWRO_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(event** tempevent) { //*************************************************** fType = kNUWRO; fNuwroEvent = *(tempevent); return; } //*************************************************** void FitEvent::NuwroKinematics() { //*************************************************** ResetEvent(); // Sort Event Info fMode = GeneratorUtils::ConvertNuwroMode(fNuwroEvent); Mode = fMode; fEventNo = 0.0; fTotCrs = 0.0; fTargetA = fNuwroEvent->par.nucleus_p + fNuwroEvent->par.nucleus_n; fTargetZ = fNuwroEvent->par.nucleus_p; fTargetH = 0; fBound = (fTargetA) == 1; // Check Particle Stack UInt_t npart_in = fNuwroEvent->in.size(); UInt_t npart_out = fNuwroEvent->out.size(); UInt_t npart_post = fNuwroEvent->post.size(); UInt_t npart = npart_in + npart_out + npart_post; if (npart > kMaxParticles) { ERR(FTL) << "NUWRO has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << " in,out,post = " << npart_in << "," << npart_out << "," << npart_post << std::endl; throw; } // Incoming Particles fNParticles = 0; for (UInt_t i = 0; i < npart_in; i++) { particle* part = &fNuwroEvent->in[i]; - fParticleMom[fNParticles][0] = part->p4().x; - fParticleMom[fNParticles][1] = part->p4().y; - fParticleMom[fNParticles][2] = part->p4().z; - fParticleMom[fNParticles][3] = part->p4().t; + fParticleMom[fNParticles][0] = part->x; + fParticleMom[fNParticles][1] = part->y; + fParticleMom[fNParticles][2] = part->z; + fParticleMom[fNParticles][3] = part->t; fParticleState[fNParticles] = kInitialState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } // FSI Particles if (!kRemoveFSIParticles) { for (UInt_t i = 0; i < npart_out; i++) { particle* part = &fNuwroEvent->out[i]; - fParticleMom[fNParticles][0] = part->p4().x; - fParticleMom[fNParticles][1] = part->p4().y; - fParticleMom[fNParticles][2] = part->p4().z; - fParticleMom[fNParticles][3] = part->p4().t; + fParticleMom[fNParticles][0] = part->x; + fParticleMom[fNParticles][1] = part->y; + fParticleMom[fNParticles][2] = part->z; + fParticleMom[fNParticles][3] = part->t; fParticleState[fNParticles] = kFSIState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } } // Final Particles for (UInt_t i = 0; i < npart_post; i++) { particle* part = &fNuwroEvent->post[i]; - fParticleMom[fNParticles][0] = part->p4().x; - fParticleMom[fNParticles][1] = part->p4().y; - fParticleMom[fNParticles][2] = part->p4().z; - fParticleMom[fNParticles][3] = part->p4().t; + fParticleMom[fNParticles][0] = part->x; + fParticleMom[fNParticles][1] = part->y; + fParticleMom[fNParticles][2] = part->z; + fParticleMom[fNParticles][3] = part->t; fParticleState[fNParticles] = kFinalState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } OrderStack(); return; }; #endif //< NuWro ifdef // REQUIRED FUNCTIONS FOR GENIE #ifdef __GENIE_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NtpMCEventRecord** tempevent) { //*************************************************** fType = kGENIE; genie_event = *tempevent; }; //*************************************************** void FitEvent::GENIEKinematics() { //*************************************************** ResetEvent(); if (!genie_event) return; if (!genie_event->event) return; genie_record = static_cast<GHepRecord*>(genie_event->event); // Extra Check for MEC if (genie_record->Summary()->ProcInfo().IsMEC()) { if (pdg::IsNeutrino(genie_record->Summary()->InitState().ProbePdg())) fMode = 2; else if (pdg::IsAntiNeutrino( genie_record->Summary()->InitState().ProbePdg())) fMode = -2; } else { fMode = utils::ghep::NeutReactionCode(genie_record); } // Set Event Info Mode = fMode; fEventNo = 0.0; fTotCrs = genie_record->XSec(); fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; InputWeight = (1E+38 / genie::units::cm2) * genie_record->XSec(); // Get N Particle Stack unsigned int npart = genie_record->GetEntries(); if (npart > kMaxParticles) { ERR(FTL) << "GENIE has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Particle Stack GHepParticle* p = 0; TObjArrayIter iter(genie_record); fNParticles = 0; /* kIStUndefined = -1, kIStInitialState = 0, / generator-level initial state / kIStStableFinalState = 1, / generator-level final state: particles to be tracked by detector-level MC / kIStIntermediateState = 2, kIStDecayedState = 3, kIStCorrelatedNucleon = 10, kIStNucleonTarget = 11, kIStDISPreFragmHadronicState = 12, kIStPreDecayResonantState = 13, kIStHadronInTheNucleus = 14, / hadrons inside the nucleus: marked for hadron transport modules to act on / kIStFinalStateNuclearRemnant = 15, / low energy nuclear fragments entering the record collectively as a 'hadronic blob' pseudo-particle / kIStNucleonClusterTarget = 16, // for composite nucleons before phase space decay */ // Loop over all particles while ((p = (dynamic_cast<genie::GHepParticle*>((iter).Next())))) { if (!p) continue; // State int state = kUndefinedState; switch (p->Status()) { case genie::kIStNucleonTarget: case genie::kIStInitialState: case genie::kIStCorrelatedNucleon: case genie::kIStNucleonClusterTarget: state = kInitialState; break; case genie::kIStStableFinalState: state = kFinalState; break; case genie::kIStHadronInTheNucleus: if (abs(fMode) == 2) state = kInitialState; else state = kFSIState; break; case genie::kIStPreDecayResonantState: case genie::kIStDISPreFragmHadronicState: case genie::kIStIntermediateState: state = kFSIState; break; case genie::kIStFinalStateNuclearRemnant: case genie::kIStUndefined: case genie::kIStDecayedState: default: break; } // Flag to remove nuclear part in genie if (p->Pdg() > 1000000) { if (state == kInitialState) state = kNuclearInitial; else if (state == kFinalState) state = kNuclearRemnant; } // if (kRemoveGenieNuclear && // (state == kNuclearInitial || state == kNuclearRemnant)){ // continue; //} // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = p->Px() * 1.E3; fParticleMom[fNParticles][1] = p->Py() * 1.E3; fParticleMom[fNParticles][2] = p->Pz() * 1.E3; fParticleMom[fNParticles][3] = p->E() * 1.E3; // PDG fParticlePDG[fNParticles] = p->Pdg(); fNParticles++; if (fNParticles == kMaxParticles) break; } OrderStack(); LOG(DEB) << "GENIE Particle Stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } return; }; #endif //< GENIE ifdef // REQUIRED FUNCTIONS FOR GIBUU #ifdef __GiBUU_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(GiBUUStdHepReader* tempevent) { //*************************************************** fType = kGiBUU; GiRead = tempevent; } //*************************************************** void FitEvent::GiBUUKinematics() { //*************************************************** ResetEvent(); LOG(DEB) << "Reading GiBUU Event: " << std::endl; LOG(DEB) << WriteGiBUUEvent(*GiRead) << std::endl; fMode = GiRead->GiBUU2NeutCode; Mode = fMode; fEventNo = 0.0; fTotCrs = 0; fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; // Extra GiBUU Input Weight InputWeight = GiRead->EvtWght; // Check Stack N int npart = GiRead->StdHepN; if ((uint)npart > kMaxParticles) { ERR(FTL) << "GiBUU has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Create Stack fNParticles = 0; for (int i = 0; i < npart; i++) { // State int state = kUndefinedState; switch (GiRead->StdHepStatus[i]) { case 0: // Incoming case 11: // Struck nucleon state = kInitialState; break; case 1: // Good Final State state = kFinalState; break; default: // Other break; } // Set Nuclear States Flag if (GiRead->StdHepPdg[i] > 1000000) { if (state == kInitialState) state = kNuclearInitial; else if (state == kFinalState) state = kNuclearRemnant; continue; } // Remove Nuclear States // if (kRemoveGiBUUNuclear && // (state == kNuclearInitial || state == kNuclearRemnant)){ // continue; //} // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; // Set State fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = GiRead->StdHepP4[i][0] * 1.E3; fParticleMom[fNParticles][1] = GiRead->StdHepP4[i][1] * 1.E3; fParticleMom[fNParticles][2] = GiRead->StdHepP4[i][2] * 1.E3; fParticleMom[fNParticles][3] = GiRead->StdHepP4[i][3] * 1.E3; // PDG fParticlePDG[fNParticles] = GiRead->StdHepPdg[i]; fNParticles++; } OrderStack(); LOG(DEB) << "GiBUU Particle Stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } } #endif //< GiBUU ifdef //*************************************************** void FitEvent::OrderStack() { //*************************************************** // Copy current stack int oldpartpdg[kMaxParticles]; int oldpartstate[kMaxParticles]; double oldpartmom[kMaxParticles][4]; int npart = fNParticles; for (int i = 0; i < npart; i++) { oldpartpdg[i] = fParticlePDG[i]; oldpartstate[i] = fParticleState[i]; oldpartmom[i][0] = fParticleMom[i][0]; oldpartmom[i][1] = fParticleMom[i][1]; oldpartmom[i][2] = fParticleMom[i][2]; oldpartmom[i][3] = fParticleMom[i][3]; } // Now run loops for each particle fNParticles = 0; int stateorder[6] = {kInitialState, kFinalState, kFSIState, kNuclearInitial, kNuclearRemnant, kUndefinedState}; for (int s = 0; s < 6; s++) { for (int i = 0; i < npart; i++) { if (oldpartstate[i] != stateorder[s]) continue; fParticlePDG[fNParticles] = oldpartpdg[i]; fParticleState[fNParticles] = oldpartstate[i]; fParticleMom[fNParticles][0] = oldpartmom[i][0]; fParticleMom[fNParticles][1] = oldpartmom[i][1]; fParticleMom[fNParticles][2] = oldpartmom[i][2]; fParticleMom[fNParticles][3] = oldpartmom[i][3]; fNParticles++; } } LOG(DEB) << "Ordered stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } if (fNParticles != npart) { ERR(FTL) << "Dropped some particles when ordering the stack!" << std::endl; } return; } // REQUIRED FUNCTIONS FOR NUANCE #ifdef __NUANCE_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NuanceEvent** tempevent) { //*************************************************** fType = kNUANCE; nuance_event = *tempevent; } //*************************************************** void FitEvent::NuanceKinematics() { //*************************************************** ResetEvent(); fMode = GeneratorUtils::ConvertNuanceMode(nuance_event); Mode = fMode; fEventNo = 0.0; fTotCrs = 1.0; fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; // Fill particle Stack fNParticles = 0; // Check Particle Stack UInt_t npart = 2 + nuance_event->n_leptons + nuance_event->n_hadrons; if (npart > kMaxParticles) { ERR(FTL) << "NUANCE has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Neutrino fParticleState[0] = kInitialState; fParticleMom[0][0] = nuance_event->p_neutrino[0]; fParticleMom[0][1] = nuance_event->p_neutrino[1]; fParticleMom[0][2] = nuance_event->p_neutrino[2]; fParticleMom[0][3] = nuance_event->p_neutrino[3]; fParticlePDG[0] = nuance_event->neutrino; // Fill Target Nucleon fParticleState[1] = kInitialState; fParticleMom[1][0] = nuance_event->p_targ[0]; fParticleMom[1][1] = nuance_event->p_targ[1]; fParticleMom[1][2] = nuance_event->p_targ[2]; fParticleMom[1][3] = nuance_event->p_targ[3]; fParticlePDG[1] = nuance_event->target; fNParticles = 2; // Fill Outgoing Leptons for (int i = 0; i < nuance_event->n_leptons; i++) { fParticleState[fNParticles] = kFinalState; fParticleMom[fNParticles][0] = nuance_event->p_lepton[i][0]; fParticleMom[fNParticles][1] = nuance_event->p_lepton[i][1]; fParticleMom[fNParticles][2] = nuance_event->p_lepton[i][2]; fParticleMom[fNParticles][3] = nuance_event->p_lepton[i][3]; fParticlePDG[fNParticles] = nuance_event->lepton[i]; fNParticles++; } // Fill Outgoing Hadrons for (int i = 0; i < nuance_event->n_hadrons; i++) { fParticleState[fNParticles] = kFinalState; fParticleMom[fNParticles][0] = nuance_event->p_hadron[i][0]; fParticleMom[fNParticles][1] = nuance_event->p_hadron[i][1]; fParticleMom[fNParticles][2] = nuance_event->p_hadron[i][2]; fParticleMom[fNParticles][3] = nuance_event->p_hadron[i][3]; fParticlePDG[fNParticles] = nuance_event->hadron[i]; fNParticles++; } } #endif /* Read/Write own event class */ void FitEvent::SetBranchAddress(TChain* tn) { fType = kINPUTFITEVENT; tn->SetBranchAddress("Mode", &fMode); tn->SetBranchAddress("Mode", &Mode); tn->SetBranchAddress("EventNo", &fEventNo); tn->SetBranchAddress("TotCrs", &fTotCrs); tn->SetBranchAddress("TargetA", &fTargetA); tn->SetBranchAddress("TargetH", &fTargetH); tn->SetBranchAddress("Bound", &fBound); tn->SetBranchAddress("InputWeight", &InputWeight); tn->SetBranchAddress("NParticles", &fNParticles); tn->SetBranchAddress("ParticleState", fParticleState); tn->SetBranchAddress("ParticlePDG", fParticlePDG); tn->SetBranchAddress("ParticleMom", fParticleMom); } void FitEvent::AddBranchesToTree(TTree* tn) { tn->Branch("Mode", &fMode, "Mode/I"); tn->Branch("EventNo", &fEventNo, "EventNo/i"); tn->Branch("TotCrs", &fTotCrs, "TotCrs/D"); tn->Branch("TargetA", &fTargetA, "TargetA/I"); tn->Branch("TargetH", &fTargetH, "TargetH/I"); tn->Branch("Bound", &fBound, "Bound/O"); tn->Branch("InputWeight", &InputWeight, "InputWeight/D"); tn->Branch("NParticles", &fNParticles, "NParticles/I"); tn->Branch("ParticleState", fParticleState, "ParticleState[NParticles]/i"); tn->Branch("ParticlePDG", fParticlePDG, "ParticlePDG[NParticles]/I"); tn->Branch("ParticleMom", fParticleMom, "ParticleMom[NParticles][4]/D"); tn->SetAlias("Enu", "ParticleMom[0][4]"); } /* Event Access Functions */ //*************************************************** FitParticle* FitEvent::PartInfo(UInt_t i) { // Check Valid if (i > (UInt_t)fNParticles or i < 0) { ERR(FTL) << "Requesting particle beyond stack!" << std::endl; ERR(FTL) << "i = " << i << " N = " << fNParticles << std::endl; ERR(FTL) << "Mode = " << fMode << std::endl; throw; } // Check particle has been formed if (!fParticleList[i]) { fParticleList[i] = new FitParticle(fParticleMom[i][0], fParticleMom[i][1], fParticleMom[i][2], fParticleMom[i][3], fParticlePDG[i], fParticleState[i]); } return fParticleList[i]; } int FitEvent::GetNeutrinoInPos(void) const { for (UInt_t i = 0; i < NPart(); i++) { if (fParticleState[i] != kInitialState) continue; if (abs(fParticlePDG[i]) == 12 || abs(fParticlePDG[i]) == 14 || abs(fParticlePDG[i]) == 16) { return i; } } return -1; } int FitEvent::GetLeptonOutPos(void) const { for (UInt_t i = 0; i < NPart(); i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) == 11 || abs(fParticlePDG[i]) == 13 || abs(fParticlePDG[i]) == 15) { return i; } } return -1; } FitParticle* FitEvent::GetBeamPart(void) { return PartInfo(GetBeamPartPos()); } FitParticle* FitEvent::GetNeutrinoIn(void) { return PartInfo(GetNeutrinoInPos()); } FitParticle* FitEvent::GetLeptonOut(void) { return PartInfo(GetLeptonOutPos()); } bool FitEvent::HasParticle(int pdg, int state) { bool found = false; for (int i = 0; i < fNParticles; i++) { if (state != -1 && fParticleState[i] != (uint)state) continue; if (fParticlePDG[i] == pdg) found = true; } return found; } int FitEvent::NumParticle(int pdg, int state) { int nfound = 0; for (int i = 0; i < fNParticles; i++) { // std::cout << "fParticlePDG[" << i << "] = " << fParticlePDG[i] << // std::endl; if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) nfound += 1; } return nfound; } int FitEvent::NumParticle(std::vector<int> pdg, int state) { int nfound = 0; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (std::find(pdg.begin(), pdg.end(), fParticlePDG[i]) != pdg.end()) nfound += 1; } return nfound; } int FitEvent::NumFSLeptons() { int nLeptons = 0; for (int i = 0; i < fNParticles; i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) == 11 || abs(fParticlePDG[i]) == 13 || abs(fParticlePDG[i]) == 15) nLeptons += 1; } return nLeptons; } int FitEvent::NumFSMesons() { int nMesons = 0; for (int i = 0; i < fNParticles; i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) >= 111 && abs(fParticlePDG[i]) <= 557) nMesons += 1; } return nMesons; } FitParticle* FitEvent::GetHMParticle(int pdg, int state) { double maxmom = -9999999.9; int maxind = -1; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) { // Update Max Mom double mom = sqrt(fParticleMom[i][0] * fParticleMom[i][0] + fParticleMom[i][1] * fParticleMom[i][1] + fParticleMom[i][2] * fParticleMom[i][2]); if (fabs(mom) > maxmom) { maxmom = fabs(mom); maxind = i; } } } if (maxind == -1) { return NULL; } return PartInfo(maxind); } FitParticle* FitEvent::GetHMParticle(std::vector<int> pdg, int state) { double maxmom = -9999999.9; int maxind = -1; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (std::find(pdg.begin(), pdg.end(), fParticlePDG[i]) != pdg.end()) { // Update Max Mom double mom = sqrt(fParticleMom[i][0] * fParticleMom[i][0] + fParticleMom[i][1] * fParticleMom[i][1] + fParticleMom[i][2] * fParticleMom[i][2]); if (fabs(mom) > maxmom) { maxmom = fabs(mom); maxind = i; } } } if (maxind == -1) { return NULL; } return PartInfo(maxind); } void FitEvent::Print() { LOG(EVT) << "FitEvent print" << std::endl; LOG(EVT) << "Mode: " << fMode << std::endl; LOG(EVT) << "Particles: " << fNParticles << std::endl; LOG(EVT) << " -> Particle Stack " << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(EVT) << " -> -> " << i << ". " << fParticlePDG[i] << " " << fParticleState[i] << " " << " Mom(" << fParticleMom[i][0] << ", " << fParticleMom[i][1] << ", " << fParticleMom[i][2] << ", " << fParticleMom[i][3] << ")." << std::endl; } return; } diff --git a/src/FitBase/FitParticle.cxx b/src/FitBase/FitParticle.cxx index 35cef1f..2de94b2 100644 --- a/src/FitBase/FitParticle.cxx +++ b/src/FitBase/FitParticle.cxx @@ -1,191 +1,199 @@ // 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 <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FitParticle.h" // NEUT Constructor #ifdef __NEUT_ENABLED__ FitParticle::FitParticle(NeutPart* part) { - // Set Momentum fP = TLorentzVector(part->fP.X(), part->fP.Y(), part->fP.Z(), part->fP.T()); fPID = part->fPID; fIsAlive = part->fIsAlive; fNEUTStatusCode = part->fStatus; fMass = part->fMass; }; // NEUT FSI defined in neutclass/neutfsipart FitParticle::FitParticle(NeutFsiPart* part) { - // Set Momentum - fP = TLorentzVector(part->fDir.X(), part->fDir.Y(), part->fDir.Z(), part->fDir.T()); + fP = TLorentzVector(part->fDir.X(), part->fDir.Y(), part->fDir.Z(), + part->fDir.T()); fPID = part->fPID; // Set these to zero because they don't make sense in NEUT fIsAlive = 0; fNEUTStatusCode = 0; fMass = fP.Mag(); }; #endif // NUWRO Constructor #ifdef __NUWRO_ENABLED__ FitParticle::FitParticle(particle* nuwro_particle, Int_t state) { // Set Momentum - this->fP = TLorentzVector(nuwro_particle->p4().x, nuwro_particle->p4().y, - nuwro_particle->p4().z, nuwro_particle->p4().t); + this->fP = TLorentzVector(nuwro_particle->x, nuwro_particle->y, + nuwro_particle->z, nuwro_particle->t); fPID = nuwro_particle->pdg; // Set status manually from switch switch (state) { case 0: fIsAlive = 0; fNEUTStatusCode = 1; break; // Initial State case 1: fIsAlive = 1; fNEUTStatusCode = 0; break; // Final State case 2: fIsAlive = 0; fNEUTStatusCode = 2; break; // Intermediate State default: fIsAlive = -1; fNEUTStatusCode = 3; break; // Other? } - fMass = nuwro_particle->m(); + fMass = fP.M(); }; #endif // GENIE Constructor #ifdef __GENIE_ENABLED__ FitParticle::FitParticle(genie::GHepParticle* genie_particle) { this->fP = TLorentzVector( genie_particle->Px() * 1000.0, genie_particle->Py() * 1000.0, genie_particle->Pz() * 1000.0, genie_particle->E() * 1000.0); fPID = genie_particle->Pdg(); switch (genie_particle->Status()) { case genie::kIStInitialState: fIsAlive = 0; fNEUTStatusCode = 1; break; // Initial State case genie::kIStStableFinalState: fIsAlive = 1; fNEUTStatusCode = 0; break; // Final State case genie::kIStIntermediateState: fIsAlive = 0; fNEUTStatusCode = 2; break; // Intermediate State default: fIsAlive = -1; fNEUTStatusCode = 3; break; } // Flag to remove nuclear part in genie if (fPID > 3000) { fIsAlive = -1; fNEUTStatusCode = 2; } fMass = genie_particle->Mass() * 1000.0; // Additional flag to remove off shell particles if (fabs(fMass - fP.Mag()) > 0.001) { fIsAlive = -1; fNEUTStatusCode = 2; } }; #endif #ifdef __GiBUU_ENABLED__ FitParticle::FitParticle(GiBUUStdHepReader* GiRead, Int_t p_it) { fPID = GiRead->StdHepPdg[p_it]; fP = TLorentzVector( GiRead->StdHepP4[p_it][0] * 1000.0, GiRead->StdHepP4[p_it][1] * 1000.0, GiRead->StdHepP4[p_it][2] * 1000.0, GiRead->StdHepP4[p_it][3] * 1000.0); fMass = fP.M(); // Flag to remove nuclear part if (fPID > 100000) { fIsAlive = -1; fNEUTStatusCode = 2; } switch (GiRead->StdHepStatus[p_it]) { case 0: { // incoming fIsAlive = 0; fNEUTStatusCode = 1; break; } case 1: { // good final state fIsAlive = 1; fNEUTStatusCode = 0; break; } case 11: { // struck nucleon fIsAlive = 0; fNEUTStatusCode = 1; break; } } } #endif FitParticle::FitParticle(UInt_t* i) { (void)i; // A NULL event has been passed // ERR(FTL)<<"NULL Event Passed to FitEvent.cxx"<<std::endl; return; }; // NUANCE Particle -FitParticle::FitParticle(double x, double y, double z, double t, int pdg, Int_t state){ - +FitParticle::FitParticle(double x, double y, double z, double t, int pdg, + Int_t state) { // Set Momentum - this->fP = TLorentzVector(x, - y, - z, - t); + this->fP = TLorentzVector(x, y, z, t); fPID = pdg; fStatus = state; // Set status manually from switch - switch(state){ - case kInitialState: fIsAlive= 0; fNEUTStatusCode=1; break; // Initial State - case kFinalState: fIsAlive= 1; fNEUTStatusCode=0; break; // Final State - case kFSIState: fIsAlive= 0; fNEUTStatusCode=2; break; // Intermediate State - default: fIsAlive=-1; fNEUTStatusCode=3; break; // Other? + switch (state) { + case kInitialState: + fIsAlive = 0; + fNEUTStatusCode = 1; + break; // Initial State + case kFinalState: + fIsAlive = 1; + fNEUTStatusCode = 0; + break; // Final State + case kFSIState: + fIsAlive = 0; + fNEUTStatusCode = 2; + break; // Intermediate State + default: + fIsAlive = -1; + fNEUTStatusCode = 3; + break; // Other? } fMass = fP.Mag(); }; diff --git a/src/FitBase/GeneratorUtils.cxx b/src/FitBase/GeneratorUtils.cxx index 2a2c0dc..920fc02 100644 --- a/src/FitBase/GeneratorUtils.cxx +++ b/src/FitBase/GeneratorUtils.cxx @@ -1,1066 +1,1183 @@ // 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 <http://www.gnu.org/licenses/>. *******************************************************************************/ #include <iostream> -#include "GeneratorUtils.h" #include "FitLogger.h" - +#include "GeneratorUtils.h" namespace GeneratorUtils { - const std::string NEUT_TreeName = "neuttree"; - const std::string NuWro_TreeName = "treeout"; - const std::string GENIE_TreeName = "gtree"; - const std::string GiBUU_TreeName = "giRooTracker"; +const std::string NEUT_TreeName = "neuttree"; +const std::string NuWro_TreeName = "treeout"; +const std::string GENIE_TreeName = "gtree"; +const std::string GiBUU_TreeName = "giRooTracker"; } #ifdef __NEUT_ENABLED__ -void GeneratorUtils::FillNeutCommons(NeutVect* nvect){ - +void GeneratorUtils::FillNeutCommons(NeutVect* nvect) { // 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; + // 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 nework_.modene = nvect->Mode; nework_.numne = nvect->Npart(); nemdls_.mdlqeaf = nvect->QEVForm; 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_.kapp = nvect->KAPPA; - //nemdls_.sccfv = SCCFVdef; - //nemdls_.sccfa = SCCFAdef; - //nemdls_.fpqe = FPQEdef; + // 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_.neiff = nvect->SPIForm; neut1pi_.nenrtype = nvect->SPINRType; - neut1pi_.rneca5i = nvect->SPICA5I; + neut1pi_.rneca5i = nvect->SPICA5I; neut1pi_.rnebgscl = nvect->SPIBGScale; nemdls_.xmacoh = nvect->COHMA; nemdls_.rad0nu = nvect->COHR0; - //nemdls_.fa1coh = nvect->COHA1err; - //nemdls_.fb1coh = nvect->COHb1err; + // nemdls_.fa1coh = nvect->COHA1err; + // nemdls_.fb1coh = nvect->COHb1err; - //neutdis_.nepdf = NEPDFdef; - //neutdis_.nebodek = NEBODEKdef; + // 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; + 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; + 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_.fefqe = nvect->NuceffFactorPIQE; + neffpr_.fefqeh = nvect->NuceffFactorPIQEH; neffpr_.fefinel = nvect->NuceffFactorPIInel; - neffpr_.fefabs = nvect->NuceffFactorPIAbs; - neffpr_.fefcx = nvect->NuceffFactorPICX; - neffpr_.fefcxh = nvect->NuceffFactorPICXH; + neffpr_.fefabs = nvect->NuceffFactorPIAbs; + neffpr_.fefcx = nvect->NuceffFactorPICX; + neffpr_.fefcxh = nvect->NuceffFactorPICXH; - neffpr_.fefcoh = nvect->NuceffFactorPICoh; + neffpr_.fefcoh = nvect->NuceffFactorPICoh; neffpr_.fefqehf = nvect->NuceffFactorPIQEHKin; neffpr_.fefcxhf = nvect->NuceffFactorPICXKin; neffpr_.fefcohf = nvect->NuceffFactorPIQELKin; - for ( int i = 0; i<nework_.numne; i++ ) { + 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 + 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 + // 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 ((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" << endl; + // ERR(WRN) << "T2KNeutUtils::fill_neut_commons(TTree) NfsiPart!=1 or + // Fsiprob!=-1 when NfsiVert==1" << endl; fsihist_.nvert = 0; fsihist_.nvcvert = 0; fsihist_.fsiprob = 1; - } - else { // Real FSI event + } else { // Real FSI event fsihist_.nvert = (int)nvect->NfsiVert(); - for (int ivert=0; ivert<fsihist_.nvert; ivert++) { + 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++) { + 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 + // 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; - - } #endif #ifdef __NIWG_ENABLED__ -niwg::rew::NIWGEvent * GeneratorUtils::GetNIWGEvent(NeutVect* nvect) -{ - niwg::rew::NIWGEvent * fDummyNIWGEvent = NULL; +niwg::rew::NIWGEvent* GeneratorUtils::GetNIWGEvent(NeutVect* nvect) { + niwg::rew::NIWGEvent* fDummyNIWGEvent = NULL; fDummyNIWGEvent = new niwg::rew::NIWGEvent(); - fDummyNIWGEvent->detid = 1; // MiniBooNE (apply CCQE LowE variations) + fDummyNIWGEvent->detid = 1; // MiniBooNE (apply CCQE LowE variations) fDummyNIWGEvent->neutmode = nvect->Mode; fDummyNIWGEvent->targetA = nvect->TargetA; fDummyNIWGEvent->recenu_ccqe_sk = -1; - if (nvect->Ibound==0) fDummyNIWGEvent->targetA = 1;//RT: identifies as H, rather than O16 + if (nvect->Ibound == 0) + fDummyNIWGEvent->targetA = 1; // RT: identifies as H, rather than O16 // Fill initial particle stack - for (int ip=0; ip<nvect->Npart(); ++ip) { - + for (int ip = 0; ip < nvect->Npart(); ++ip) { niwg::rew::NIWGPartStack fDummyPartStack; - fDummyPartStack.p = (nvect->PartInfo(ip)->fP)*0.001; // Convert to GeV + fDummyPartStack.p = (nvect->PartInfo(ip)->fP) * 0.001; // Convert to GeV fDummyPartStack.pdg = nvect->PartInfo(ip)->fPID; fDummyPartStack.chase = nvect->PartInfo(ip)->fIsAlive; - fDummyPartStack.parent = nvect->ParentIdx(ip)-1; // WARNING: this needs to be tested with a NeutRoot file + fDummyPartStack.parent = + nvect->ParentIdx(ip) - + 1; // WARNING: this needs to be tested with a NeutRoot file fDummyNIWGEvent->part_stack.push_back(fDummyPartStack); } fDummyNIWGEvent->CalcKinematics(); return fDummyNIWGEvent; } -#endif // neut enabled - +#endif // neut enabled #ifdef __NUWRO_ENABLED__ + +int nof(event* e, int pdg) { + int c = 0; + for (size_t i = 0; i < e->out.size(); i++) + if (e->out[i].pdg == pdg) c++; + return c; +} + //*************************************************** -int GeneratorUtils::ConvertNuwroMode (event * e) +int GeneratorUtils::ConvertNuwroMode(event* e) //*************************************************** { - - Int_t proton_pdg, neutron_pdg, pion_pdg, pion_plus_pdg, pion_minus_pdg, - lambda_pdg, eta_pdg, kaon_pdg, kaon_plus_pdg; + lambda_pdg, eta_pdg, kaon_pdg, kaon_plus_pdg; proton_pdg = 2212; eta_pdg = 221; neutron_pdg = 2112; pion_pdg = 111; pion_plus_pdg = 211; pion_minus_pdg = -211; - //O_16_pdg = 100069; // oznacznie z Neuta + // O_16_pdg = 100069; // oznacznie z Neuta lambda_pdg = 3122; kaon_pdg = 311; kaon_plus_pdg = 321; - - if (e->flag.qel) // kwiazielastyczne oddziaływanie + if (e->flag.qel) // kwiazielastyczne oddziaływanie + { + if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { - if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem - { - if (e->flag.cc) - return -1; - else - { - if (e->nof (proton_pdg)) - return -51; - else if (e->nof (neutron_pdg)) - return -52; // sprawdzam dodatkowo ? - } - } - else // oddziaływanie z neutrinem - { - if (e->flag.cc) - return 1; - else - { - if (e->nof (proton_pdg)) - return 51; - else if (e->nof (neutron_pdg)) - return 52; - } - } + if (e->flag.cc) + return -1; + else { + if (nof(e, proton_pdg)) + return -51; + else if (nof(e, neutron_pdg)) + return -52; // sprawdzam dodatkowo ? + } + } else // oddziaływanie z neutrinem + { + if (e->flag.cc) + return 1; + else { + if (nof(e, proton_pdg)) + return 51; + else if (nof(e, neutron_pdg)) + return 52; + } } + } - if (e->flag.mec){ - if (e->flag.anty) return -2; - else return 2; + if (e->flag.mec) { + if (e->flag.anty) + return -2; + else + return 2; } + if (e->flag.res) // rezonansowa produkcja: pojedynczy pion, pojed.eta, kaon, + // multipiony + { + Int_t liczba_pionow, liczba_kaonow; + + liczba_pionow = + nof(e, pion_pdg) + nof(e, pion_plus_pdg) + nof(e, pion_minus_pdg); + liczba_kaonow = nof(e, kaon_pdg) + nof(e, kaon_pdg); - if (e->flag.res) //rezonansowa produkcja: pojedynczy pion, pojed.eta, kaon, multipiony + if (liczba_pionow > 1 || liczba_pionow == 0) // multipiony { + if (e->flag.anty) { + if (e->flag.cc) + return -21; + else + return -41; + } else { + if (e->flag.cc) + return 21; + else + return 41; + } + } - Int_t liczba_pionow, liczba_kaonow; - - liczba_pionow = - e->nof (pion_pdg) + e->nof (pion_plus_pdg) + e->nof (pion_minus_pdg); - liczba_kaonow = e->nof (kaon_pdg) + e->nof (kaon_pdg); - - if (liczba_pionow > 1 || liczba_pionow == 0) // multipiony - { - if (e->flag.anty) - { - if (e->flag.cc) - return -21; - else - return -41; - } - else - { - if (e->flag.cc) - return 21; - else - return 41; - } - } - - if (liczba_pionow == 1) - { - if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem - { - if (e->flag.cc) - { - if (e->nof (neutron_pdg) && e->nof (pion_minus_pdg)) - return -11; - if (e->nof (neutron_pdg) && e->nof (pion_pdg)) - return -12; - if (e->nof (proton_pdg) && e->nof (pion_minus_pdg)) - return -13; - } - else - { - if (e->nof (proton_pdg)) - { - if (e->nof (pion_minus_pdg)) - return -33; - else if (e->nof (pion_pdg)) - return -32; - } - else if (e->nof (neutron_pdg)) - { - if (e->nof (pion_plus_pdg)) - return -34; - else if (e->nof (pion_pdg)) - return -31; - } - } - } - else // oddziaływanie z neutrinem - { - if (e->flag.cc) - { - if (e->nof (proton_pdg) && e->nof (pion_plus_pdg)) - return 11; - if (e->nof (proton_pdg) && e->nof (pion_pdg)) - return 12; - if (e->nof (neutron_pdg) && e->nof (pion_plus_pdg)) - return 13; - } - else - { - if (e->nof (proton_pdg)) - { - if (e->nof (pion_minus_pdg)) - return 33; - else if (e->nof (pion_pdg)) - return 32; - } - else if (e->nof (neutron_pdg)) - { - if (e->nof (pion_plus_pdg)) - return 34; - else if (e->nof (pion_pdg)) - return 31; - } - } - } - } - - if (e->nof (eta_pdg)) // produkcja rezonansowa ety - { - if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem - { - if (e->flag.cc) - return -22; - else - { - if (e->nof (neutron_pdg)) - return -42; - else if (e->nof (proton_pdg)) - return -43; // sprawdzam dodatkowo ? - } - } - else // oddziaływanie z neutrinem - { - if (e->flag.cc) - return 22; - else - { - if (e->nof (neutron_pdg)) - return 42; - else if (e->nof (proton_pdg)) - return 43; - } - } - } - - if (e->nof (lambda_pdg) == 1 && liczba_kaonow == 1) // produkcja rezonansowa kaonu - { - if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem - { - if (e->flag.cc && e->nof (kaon_pdg)) - return -23; - else - { - if (e->nof (kaon_pdg)) - return -44; - else if (e->nof (kaon_plus_pdg)) - return -45; - } - } - else // oddziaływanie z neutrinem - { - if (e->flag.cc && e->nof (kaon_plus_pdg)) - return 23; - else - { - if (e->nof (kaon_pdg)) - return 44; - else if (e->nof (kaon_plus_pdg)) - return 45; - } - } - - - } + if (liczba_pionow == 1) { + if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem + { + if (e->flag.cc) { + if (nof(e, neutron_pdg) && nof(e, pion_minus_pdg)) return -11; + if (nof(e, neutron_pdg) && nof(e, pion_pdg)) return -12; + if (nof(e, proton_pdg) && nof(e, pion_minus_pdg)) return -13; + } else { + if (nof(e, proton_pdg)) { + if (nof(e, pion_minus_pdg)) + return -33; + else if (nof(e, pion_pdg)) + return -32; + } else if (nof(e, neutron_pdg)) { + if (nof(e, pion_plus_pdg)) + return -34; + else if (nof(e, pion_pdg)) + return -31; + } + } + } else // oddziaływanie z neutrinem + { + if (e->flag.cc) { + if (nof(e, proton_pdg) && nof(e, pion_plus_pdg)) return 11; + if (nof(e, proton_pdg) && nof(e, pion_pdg)) return 12; + if (nof(e, neutron_pdg) && nof(e, pion_plus_pdg)) return 13; + } else { + if (nof(e, proton_pdg)) { + if (nof(e, pion_minus_pdg)) + return 33; + else if (nof(e, pion_pdg)) + return 32; + } else if (nof(e, neutron_pdg)) { + if (nof(e, pion_plus_pdg)) + return 34; + else if (nof(e, pion_pdg)) + return 31; + } + } + } + } + if (nof(e, eta_pdg)) // produkcja rezonansowa ety + { + if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem + { + if (e->flag.cc) + return -22; + else { + if (nof(e, neutron_pdg)) + return -42; + else if (nof(e, proton_pdg)) + return -43; // sprawdzam dodatkowo ? + } + } else // oddziaływanie z neutrinem + { + if (e->flag.cc) + return 22; + else { + if (nof(e, neutron_pdg)) + return 42; + else if (nof(e, proton_pdg)) + return 43; + } + } } - if (e->flag.coh) // koherentne oddziaływanie tylko na O(16) + if (nof(e, lambda_pdg) == 1 && + liczba_kaonow == 1) // produkcja rezonansowa kaonu { - Int_t _target; - _target = e->par.nucleus_p + e->par.nucleus_n; // liczba masowa O(16) - - if (_target == 16) - { - if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem - { - if (e->flag.cc && e->nof (pion_minus_pdg)) - return -16; - else if (e->nof (pion_pdg)) - return -36; - } - else // oddziaływanie z neutrinem - { - if (e->flag.cc && e->nof (pion_plus_pdg)) - return 16; - else if (e->nof (pion_pdg)) - return 36; - } - } + if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem + { + if (e->flag.cc && nof(e, kaon_pdg)) + return -23; + else { + if (nof(e, kaon_pdg)) + return -44; + else if (nof(e, kaon_plus_pdg)) + return -45; + } + } else // oddziaływanie z neutrinem + { + if (e->flag.cc && nof(e, kaon_plus_pdg)) + return 23; + else { + if (nof(e, kaon_pdg)) + return 44; + else if (nof(e, kaon_plus_pdg)) + return 45; + } + } } + } + + if (e->flag.coh) // koherentne oddziaływanie tylko na O(16) + { + Int_t _target; + _target = e->par.nucleus_p + e->par.nucleus_n; // liczba masowa O(16) + + if (_target == 16) { + if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem + { + if (e->flag.cc && nof(e, pion_minus_pdg)) + return -16; + else if (nof(e, pion_pdg)) + return -36; + } else // oddziaływanie z neutrinem + { + if (e->flag.cc && nof(e, pion_plus_pdg)) + return 16; + else if (nof(e, pion_pdg)) + return 36; + } + } + } // gleboko nieelastyczne rozpraszanie - if (e->flag.dis) - { - if (e->flag.anty) - { - if (e->flag.cc) - return -26; - else - return -46; - } + if (e->flag.dis) { + if (e->flag.anty) { + if (e->flag.cc) + return -26; else - { - if (e->flag.cc) - return 26; - else - return 46; - } + return -46; + } else { + if (e->flag.cc) + return 26; + else + return 46; } + } return 9999; } - #endif - #ifdef __NUANCE_ENABLED__ -int GeneratorUtils::ConvertNuanceMode(NuanceEvent * evt){ +int GeneratorUtils::ConvertNuanceMode(NuanceEvent* evt) { int ch = evt->channel; int sg = 1; if (evt->neutrino < 0) sg = -1; - switch(ch){ - // 1 NUANCE CCQE -> NEUT CCQE 1 - case 1: return sg*1; - // 2 NUANCE NCEL -> NEUT NCEL 51,52 -> Set from whether target is p or n - case 2: - if (evt->target == 2212) return sg*51; - else return sg*52; - - // 3 NUANCE CCPIP -> NEUT CCPIP 11 - case 3: return sg*11; - // 4 NUANCE CCPI0 -> NEUT CCPI0 = 12 - case 4: return sg*12; - // 5 NUANCE CCPIPn -> NEUT CCPIPn 13 - case 5: return sg*13; - // 6 NUANCE NCpPI0 -> NEUT NCpPI0 32 - case 6: return sg*32; - // 7 NUANCE NCpPI+ -> NEUT NCpPI+ 34 - case 7: return sg*34; - // 8 NUANCE NCnPI0 -> NEUT NCnPI0 31 - case 8: return sg*31; - // 9 NUANCE NCnPIM -> NEUT NCnPIM 33 - case 9: return sg*33; - // 10 NUANCE CCPIP -> NEUT CCPIP -11 - case 10: return sg*11; - // 11 NUANCE CCPI0 -> NEUT CCPI0 -12 - case 11: return sg*12; - // 12 NUANCE CCPIPn -> NEUT CCPIPn 13 - case 12: return sg*13; - // 13 NUANCE NCpPI0 -> NEUT NCnPI0 -32 - case 13: return sg*32; - // 14 NUANCE NCpPI+ -> NEUT NCpPI+ -34 - case 14: return sg*34; - // 15 NUANCE NCnPI0 -> NEUT NCnPI0 -31 - case 15: return sg*31; - // 16 NUANCE NCnPIM -> NEUT NCnPIM -33 - case 16: return sg*33; - // 17 NUANCE -> NEUT 21 CC MULTIPI - case 17: return sg*21; - // 18 NUANCE -> NEUT 21 CC MULTIPI - case 18: return sg*21; - // 19 NUANCE -> NEUT 21 CC MULTIPI - case 19: return sg*21; - // 20 NUANCE -> NEUT 21 CC MULTIPI - case 20: return sg*21; - // 21 NUANCE -> NEUT 21 CC MULTIPI - case 21: return sg*21; - // 22 NUANCE -> NEUT 41 NC MULTIPI - case 22: return sg*41; - // 23 NUANCE -> NEUT 41 NC MULTIPI - case 23: return sg*41; - // 24 NUANCE -> NEUT 41 NC MULTIPI - case 24: return sg*41; - // 25 NUANCE -> NEUT 41 NC MULTIPI - case 25: return sg*41; - // 26 NUANCE -> NEUT 41 NC MULTIPI - case 26: return sg*41; - // 27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 27: return sg*41; - // 28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) - case 28: return sg*21; - // 29 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) - case 29: return sg*21; - // 30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) - case 30: return sg*21; - // 31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) - case 31: return sg*21; - // 32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) - case 32: return sg*21; - // 33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 33: return sg*41; - // 34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 34: return sg*41; - // 35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 35: return sg*41; - // 36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 36: return sg*41; - // 37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 37: return sg*41; - // 38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) - case 38: return sg*41; - - // 39 NUANCE -> NEUT 22 - case 39: return sg*22; - // 40 NUANCE -> NEUT 22 - case 40: return sg*22; - // 41 NUANCE -> NEUT 22 - case 41: return sg*22; - // 42 NUANCE -> NEUT 43 - case 42: return sg*43; - // 43 NUANCE -> NEUT 43 - case 43: return sg*43; - // 44 NUANCE -> NUET 42 - case 44: return sg*42; - // 45 NUANCE -> NEUT -42 - case 45: return sg*42; - // 46 NUANCE -> NEUT -22 - case 46: return sg*22; - // 47 NUANCE -> NEUT -22 - case 47: return sg*22; - // 48 NUANCE -> NEUT -22 - case 48: return sg*22; - // 49 NUANCE -> NEUT -43 - case 49: return sg*43; - // 50 NUANCE -> NEUT -43 - case 50: return sg*43; - // 51 NUANCE -> NEUT -42 - case 51: return sg*42; - // 52 NUANCE -> NEUT -42 - case 52: return sg*42; - - // 53 NUANCE -> NEUT 23 CC 1K - case 53: return sg*23; - // 54 NUANCE -> NEUT 23 CC 1K - case 54: return sg*23; - // 55 NUANCE -> NEUT 23 CC 1K - case 55: return sg*23; - // 56 NUANCE -> NEUT 45 NC 1K - case 56: return sg*45; - // 57 NUANCE -> NEUT 44 NC 1K - case 57: return sg*44; - // 58 NUANCE -> NEUT 44 NC 1K - case 58: return sg*44; - // 59 NUANCE -> NEUT 44 NC 1K - case 59: return sg*44; - // 60 NUANCE -> NEUT -23 CC 1K - case 60: return sg*23; - // 61 NUANCE -> NEUT -23 CC 1K - case 61: return sg*23; - // 62 NUANCE -> NEUT -23 CC 1K - case 62: return sg*23; - // 63 NUANCE -> NEUT -23 CC 1K - case 63: return sg*23; - // 64 NUANCE -> NEUT -44 NC 1K - case 64: return sg*44; - // 65 NUANCE -> NEUT -44 NC 1K - case 65: return sg*44; - // 66 NUANCE -> NEUT -45 NC 1K - case 66: return sg*45; - // 67 NUANCE -> NEUT 22 CC1eta - case 67: return sg*22; - // 68 NUANCE -> NEUT 43 NC p eta - case 68: return sg*43; - // 69 NUANCE -> NEUT 43 NC n eta - case 69: return sg*43; - // 70 NUANCE -> NEUT -22 CC1eta - case 70: return sg*22; - // 71 NUANCE -> NEUT -43 NC p eta - case 71: return sg*43; - // 72 NUANCE -> NEUT 42 NC n eta - case 72: return sg*42; - - // 73 NUANCE -> NEUT 21 CC Multi Pi - case 73: return sg*21; - // 74 NUANCE -> NEUT 41 NC Multi Pi - case 74: return sg*41; - // 75 NUANCE -> NEUT 41 NC Multi Pi - case 75: return sg*41; - // 76 NUANCE -> NEUT -21 CC Multi Pi - case 76: return sg*21; - // 77 NUANCE -> NEUT -41 NC Multi Pi - case 77: return sg*41; - // 78 NUANCE -> NEUT -41 NC Multi Pi - case 78: return sg*41; - // 79 NUANCE -> NEUT 21 CC Multi Pi - case 79: return sg*21; - // 80 NUANCE -> NEUT 21 CC Multi Pi - case 80: return sg*21; - // 81 NUANCE -> NEUT 41 NC Multi Pi - case 81: return sg*41; - // 82 NUANCE -> NEUT 41 NC Multi Pi - case 82: return sg*41; - // 83 NUANCE -> NEUT 41 NC Multi Pi - case 83: return sg*41; - // 84 NUANCE -> NEUT 41 NC Multi Pi - case 84: return sg*84; - // 85 NUANCE -> NEUT -21 CC Multi Pi - case 85: return sg*21; - // 86 NUANCE -> NEUT -21 CC Multi Pi - case 86: return sg*21; - // 87 NUANCE -> NEUT -41 CC Multi Pi - case 87: return sg*41; - // 88 NUANCE -> NEUT -41 - case 88: return sg*41; - // 89 NUANCE -> NEUT -41 - case 89: return sg*41; - // 90 NUANCE -> NEUT -41 - case 90: return sg*41; - - // 91 NUANCE -> NEUT 26 CC DIS - case 91: return sg*26; - // 92 NUANCE -> NEUT 46 NC DIS - case 92: return sg*46; - // 93 NUANCE -> NEUT 17 1#gamma from #Delta - case 93: return sg*17; - // 94 NUANCE -> NEUT 39 1#gamma from #Delta - case 94: return sg*39; - // 95 -> UNKOWN NEUT MODE - case 95: return sg*0; - // 96 NUANCE -> NEUT 36 NC COH - case 96: return sg*36; - // 97 NUANCE -> NEUT 16 - case 97: return sg*16; - // 98 -> UNKNOWN NEUT MODE - case 98: return sg*0; - // 99 -> UNKNOWN NEUT MODE - case 99: return sg*0; - default: - ERR(FTL) << "Unknown Nuance Channel ID = "<<ch<<std::endl; - throw("Exiting."); - return 0; + switch (ch) { + // 1 NUANCE CCQE -> NEUT CCQE 1 + case 1: + return sg * 1; + // 2 NUANCE NCEL -> NEUT NCEL 51,52 -> Set from whether target is p or n + case 2: + if (evt->target == 2212) + return sg * 51; + else + return sg * 52; + + // 3 NUANCE CCPIP -> NEUT CCPIP 11 + case 3: + return sg * 11; + // 4 NUANCE CCPI0 -> NEUT CCPI0 = 12 + case 4: + return sg * 12; + // 5 NUANCE CCPIPn -> NEUT CCPIPn 13 + case 5: + return sg * 13; + // 6 NUANCE NCpPI0 -> NEUT NCpPI0 32 + case 6: + return sg * 32; + // 7 NUANCE NCpPI+ -> NEUT NCpPI+ 34 + case 7: + return sg * 34; + // 8 NUANCE NCnPI0 -> NEUT NCnPI0 31 + case 8: + return sg * 31; + // 9 NUANCE NCnPIM -> NEUT NCnPIM 33 + case 9: + return sg * 33; + // 10 NUANCE CCPIP -> NEUT CCPIP -11 + case 10: + return sg * 11; + // 11 NUANCE CCPI0 -> NEUT CCPI0 -12 + case 11: + return sg * 12; + // 12 NUANCE CCPIPn -> NEUT CCPIPn 13 + case 12: + return sg * 13; + // 13 NUANCE NCpPI0 -> NEUT NCnPI0 -32 + case 13: + return sg * 32; + // 14 NUANCE NCpPI+ -> NEUT NCpPI+ -34 + case 14: + return sg * 34; + // 15 NUANCE NCnPI0 -> NEUT NCnPI0 -31 + case 15: + return sg * 31; + // 16 NUANCE NCnPIM -> NEUT NCnPIM -33 + case 16: + return sg * 33; + // 17 NUANCE -> NEUT 21 CC MULTIPI + case 17: + return sg * 21; + // 18 NUANCE -> NEUT 21 CC MULTIPI + case 18: + return sg * 21; + // 19 NUANCE -> NEUT 21 CC MULTIPI + case 19: + return sg * 21; + // 20 NUANCE -> NEUT 21 CC MULTIPI + case 20: + return sg * 21; + // 21 NUANCE -> NEUT 21 CC MULTIPI + case 21: + return sg * 21; + // 22 NUANCE -> NEUT 41 NC MULTIPI + case 22: + return sg * 41; + // 23 NUANCE -> NEUT 41 NC MULTIPI + case 23: + return sg * 41; + // 24 NUANCE -> NEUT 41 NC MULTIPI + case 24: + return sg * 41; + // 25 NUANCE -> NEUT 41 NC MULTIPI + case 25: + return sg * 41; + // 26 NUANCE -> NEUT 41 NC MULTIPI + case 26: + return sg * 41; + // 27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 27: + return sg * 41; + // 28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) + case 28: + return sg * 21; + // 29 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) + case 29: + return sg * 21; + // 30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) + case 30: + return sg * 21; + // 31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) + case 31: + return sg * 21; + // 32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) + case 32: + return sg * 21; + // 33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 33: + return sg * 41; + // 34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 34: + return sg * 41; + // 35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 35: + return sg * 41; + // 36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 36: + return sg * 41; + // 37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 37: + return sg * 41; + // 38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) + case 38: + return sg * 41; + + // 39 NUANCE -> NEUT 22 + case 39: + return sg * 22; + // 40 NUANCE -> NEUT 22 + case 40: + return sg * 22; + // 41 NUANCE -> NEUT 22 + case 41: + return sg * 22; + // 42 NUANCE -> NEUT 43 + case 42: + return sg * 43; + // 43 NUANCE -> NEUT 43 + case 43: + return sg * 43; + // 44 NUANCE -> NUET 42 + case 44: + return sg * 42; + // 45 NUANCE -> NEUT -42 + case 45: + return sg * 42; + // 46 NUANCE -> NEUT -22 + case 46: + return sg * 22; + // 47 NUANCE -> NEUT -22 + case 47: + return sg * 22; + // 48 NUANCE -> NEUT -22 + case 48: + return sg * 22; + // 49 NUANCE -> NEUT -43 + case 49: + return sg * 43; + // 50 NUANCE -> NEUT -43 + case 50: + return sg * 43; + // 51 NUANCE -> NEUT -42 + case 51: + return sg * 42; + // 52 NUANCE -> NEUT -42 + case 52: + return sg * 42; + + // 53 NUANCE -> NEUT 23 CC 1K + case 53: + return sg * 23; + // 54 NUANCE -> NEUT 23 CC 1K + case 54: + return sg * 23; + // 55 NUANCE -> NEUT 23 CC 1K + case 55: + return sg * 23; + // 56 NUANCE -> NEUT 45 NC 1K + case 56: + return sg * 45; + // 57 NUANCE -> NEUT 44 NC 1K + case 57: + return sg * 44; + // 58 NUANCE -> NEUT 44 NC 1K + case 58: + return sg * 44; + // 59 NUANCE -> NEUT 44 NC 1K + case 59: + return sg * 44; + // 60 NUANCE -> NEUT -23 CC 1K + case 60: + return sg * 23; + // 61 NUANCE -> NEUT -23 CC 1K + case 61: + return sg * 23; + // 62 NUANCE -> NEUT -23 CC 1K + case 62: + return sg * 23; + // 63 NUANCE -> NEUT -23 CC 1K + case 63: + return sg * 23; + // 64 NUANCE -> NEUT -44 NC 1K + case 64: + return sg * 44; + // 65 NUANCE -> NEUT -44 NC 1K + case 65: + return sg * 44; + // 66 NUANCE -> NEUT -45 NC 1K + case 66: + return sg * 45; + // 67 NUANCE -> NEUT 22 CC1eta + case 67: + return sg * 22; + // 68 NUANCE -> NEUT 43 NC p eta + case 68: + return sg * 43; + // 69 NUANCE -> NEUT 43 NC n eta + case 69: + return sg * 43; + // 70 NUANCE -> NEUT -22 CC1eta + case 70: + return sg * 22; + // 71 NUANCE -> NEUT -43 NC p eta + case 71: + return sg * 43; + // 72 NUANCE -> NEUT 42 NC n eta + case 72: + return sg * 42; + + // 73 NUANCE -> NEUT 21 CC Multi Pi + case 73: + return sg * 21; + // 74 NUANCE -> NEUT 41 NC Multi Pi + case 74: + return sg * 41; + // 75 NUANCE -> NEUT 41 NC Multi Pi + case 75: + return sg * 41; + // 76 NUANCE -> NEUT -21 CC Multi Pi + case 76: + return sg * 21; + // 77 NUANCE -> NEUT -41 NC Multi Pi + case 77: + return sg * 41; + // 78 NUANCE -> NEUT -41 NC Multi Pi + case 78: + return sg * 41; + // 79 NUANCE -> NEUT 21 CC Multi Pi + case 79: + return sg * 21; + // 80 NUANCE -> NEUT 21 CC Multi Pi + case 80: + return sg * 21; + // 81 NUANCE -> NEUT 41 NC Multi Pi + case 81: + return sg * 41; + // 82 NUANCE -> NEUT 41 NC Multi Pi + case 82: + return sg * 41; + // 83 NUANCE -> NEUT 41 NC Multi Pi + case 83: + return sg * 41; + // 84 NUANCE -> NEUT 41 NC Multi Pi + case 84: + return sg * 84; + // 85 NUANCE -> NEUT -21 CC Multi Pi + case 85: + return sg * 21; + // 86 NUANCE -> NEUT -21 CC Multi Pi + case 86: + return sg * 21; + // 87 NUANCE -> NEUT -41 CC Multi Pi + case 87: + return sg * 41; + // 88 NUANCE -> NEUT -41 + case 88: + return sg * 41; + // 89 NUANCE -> NEUT -41 + case 89: + return sg * 41; + // 90 NUANCE -> NEUT -41 + case 90: + return sg * 41; + + // 91 NUANCE -> NEUT 26 CC DIS + case 91: + return sg * 26; + // 92 NUANCE -> NEUT 46 NC DIS + case 92: + return sg * 46; + // 93 NUANCE -> NEUT 17 1#gamma from #Delta + case 93: + return sg * 17; + // 94 NUANCE -> NEUT 39 1#gamma from #Delta + case 94: + return sg * 39; + // 95 -> UNKOWN NEUT MODE + case 95: + return sg * 0; + // 96 NUANCE -> NEUT 36 NC COH + case 96: + return sg * 36; + // 97 NUANCE -> NEUT 16 + case 97: + return sg * 16; + // 98 -> UNKNOWN NEUT MODE + case 98: + return sg * 0; + // 99 -> UNKNOWN NEUT MODE + case 99: + return sg * 0; + default: + ERR(FTL) << "Unknown Nuance Channel ID = " << ch << std::endl; + throw("Exiting."); + return 0; } return 0; - } #endif /* // Notes copied from NuanceChannels.pdf 1 NUANCE CCQE -> NEUT CCQE 1 CC, numu n --> mu- p Cabibbo-allowed quasi-elastic scattering from nucleons 2 NUANCE NCEL -> NEUT NCEL 51,52 -> Set from whether target is p or n NC, numu N --> num N, (N=n,p) (quasi)-elastic scattering from nucleons 3 NUANCE CCPIP -> NEUT CCPIP 11 CC, numu p --> mu- p pi+ resonant single pion production 4 NUANCE CCPI0 -> NEUT CCPI0 = 12 CC, numu n --> mu- p pi0 resonant single pion production 5 NUANCE CCPIPn -> NEUT CCPIPn 13 CC, numu n --> mu- n pi+ resonant single pion production 6 NUANCE NCpPI0 -> NEUT NCpPI0 32 NC, numu p --> numu p pi0 resonant single pion production 7 NUANCE NCpPI+ -> NEUT NCpPI+ 34 NC, numu p --> numu n pi+ resonant single pion production 8 NUANCE NCnPI0 -> NEUT NCnPI0 31 NC, numu n --> numu n pi0 resonant single pion production 9 NUANCE NCnPIM -> NEUT NCnPIM 33 NC, numu n --> numu p pi- resonant single pion production 10 NUANCE CCPIP -> NEUT CCPIP -11 CC, numubar p --> mu- p pi+ resonant single pion production 11 NUANCE CCPI0 -> NEUT CCPI0 -12 CC, numubar n --> mu- p pi0 resonant single pion production 12 NUANCE CCPIPn -> NEUT CCPIPn -13 CC, numubar n --> mu- n pi+ resonant single pion production 13 NUANCE NCpPI0 -> NEUT NCnPI0 -32 NC, numubar p --> numubar p pi0 resonant single pion production 14 NUANCE NCpPI+ -> NEUT NCpPI+ -34 NC, numubar p --> numubar n pi+ resonant single pion production 15 NUANCE NCnPI0 -> NEUT NCnPI0 -31 NC, numubar n --> numubar n pi0 resonant single pion production 16 NUANCE NCnPIM -> NEUT NCnPIM -33 NC, numubar n --> numubar p pi- resonant single pion production -17 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +17 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numu p --> mu- Delta+ pi+ resonant processes involving more than a single pion -18 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +18 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numu p --> mu- Delta++ pi0 resonant processes involving more than a single pion -19 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +19 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numu n --> mu- Delta+ pi0 resonant processes involving more than a single pion -20 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +20 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numu n --> mu- Delta0 pi+ resonant processes involving more than a single pion -21 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +21 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numu n --> mu- Delta++ pi- resonant processes involving more than a single pion -22 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +22 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numu p+ --> numu Delta+ pi0 resonant processes involving more than a single pion -23 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +23 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC,numu p --> numu Delta0 pi+ resonant processes involving more than a single pion -24 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +24 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numu p --> numu Delta++ pi- resonant processes involving more than a single pion -25 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +25 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numu n --> numu Delta+ pi- resonant processes involving more than a single pion -26 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +26 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numu n --> numu Delta0 pi0 resonant processes involving more than a single pion -27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar n --> numubar Delta- pi+ resonant processes involving more than a single pion -28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numubar p --> mu- Delta+ pi+ resonant processes involving more than a single pion -29 UANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +29 UANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numubar p --> mu- Delta++ pi0 resonant processes involving more than a single pion -30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numubar n --> mu- Delta+ pi0 resonant processes involving more than a single pion -31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numubar n --> mu- Delta0 pi+ resonant processes involving more than a single pion -32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi +32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' +multi-#pi CC, numubar n --> mu- Delta++ pi- resonant processes involving more than a single pion -33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar p+ --> numubar Delta+ pi0 resonant processes involving more than a single pion -34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC,numubar p --> numubar Delta0 pi+ resonant processes involving more than a single pion -35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar p --> numubar Delta++ pi- resonant processes involving more than a single pion -36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar n --> numubar Delta+ pi- resonant processes involving more than a single pion -37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar n --> numubar Delta0 pi0 resonant processes involving more than a single pion -38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" +38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N +multi-#pi" NC, numubar n --> numubar Delta- pi+ resonant processes involving more than a single pion // RHO Production lumped in with eta production 22 CCeta 43 NCeta on p 42 NCeta on n 39 NUANCE -> NEUT 22 CC, numu p --> mu- p rho+(770) resonant processes involving more than a single pion 40 NUANCE -> NEUT 22 CC, numu n --> mu- p rho0(770) resonant processes involving more than a single pion 41 NUANCE -> NEUT 22 CC, numu n --> mu- n rho+(770) resonant processes involving more than a single pion 42 NUANCE -> NEUT 43 NC, numu p --> numu p rho0(770) resonant processes involving more than a single pion 43 NUANCE -> NEUT 43 NC, numu p --> numu n rho+(770) resonant processes involving more than a single pion 44 NUANCE -> NUET 42 NC, numu n --> numu n rho0(770) resonant processes involving more than a single pion 45 NUANCE -> NEUT -42 NC, numubar n --> numubar p rho-(770) resonant processes involving more than a single pion 46 NUANCE -> NEUT -22 CC, numubar p --> mu- p rho+(770) resonant processes involving more than a single pion 47 NUANCE -> NEUT -22 CC, numubar n --> mu- p rho0(770) resonant processes involving more than a single pion 48 NUANCE -> NEUT -22 CC, numubar n --> mu- n rho+(770) resonant processes involving more than a single pion 49 NUANCE -> NEUT -43 NC, numubar p --> numubar p rho0(770) resonant processes involving more than a single pion 50 NUANCE -> NEUT -43 NC, numubar p --> numubar n rho+(770) resonant processes involving more than a single pion 51 NUANCE -> NEUT -42 NC, numubar n --> numubar n rho0(770) resonant processes involving more than a single pion 52 NUANCE -> NEUT -42 NC, numubar n --> numubar p rho-(770) resonant processes involving more than a single pion 53 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu p --> mu- Sigma+ K+ resonant processes involving more than a single pion 54 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu n --> mu- Sigma0 K+ resonant processes involving more than a single pion 55 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu n --> mu- Sigma+ K0 resonant processes involving more than a single pion 56 NUANCE -> NEUT 45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numu p --> numu Sigma0 K+ resonant processes involving more than a single pion 57 NUANCE -> NEUT 44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numu p --> numu Sigma+ K0 resonant processes involving more than a single pion 58 NUANCE -> NEUT 44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numu n --> numu Sigma0 K0 resonant processes involving more than a single pion 59 NUANCE -> NEUT 45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numu n --> numu Sigma- K+ resonant processes involving more than a single pion 60 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar p --> mu- Sigma+ K+ resonant processes involving more than a single pion 61 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar n --> mu- Sigma0 K+ resonant processes involving more than a single pion 62 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar n --> mu- Sigma+ K0 resonant processes involving more than a single pion 63 NUANCE -> NEUT -45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numubar p --> numubar Sigma0 K+ resonant processes involving more than a single pion 64 NUANCE -> NEUT -44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numubar p --> numubar Sigma+ K0 resonant processes involving more than a single pion 65 NUANCE -> NEUT -44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numubar n --> numubar Sigma0 K0 resonant processes involving more than a single pion 66 NUANCE -> NEUT -45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numubar n --> numubar Sigma- K+ resonant processes involving more than a single pion 67 NUANCE -> NEUT 22 ModeStack[22]->SetTitle("CC1#eta^{0} on n"); CC, numu n --> mu- p eta resonant processes involving more than a single pion 68 NUANCE -> NEUT 43 NC, numu p --> numu p eta resonant processes involving more than a single pion 69 NUANCE -> NEUT 42 NC, numu n --> numu n eta resonant processes involving more than a single pion 70 NUANCE -> NEUT -22 ModeStack[22]->SetTitle("CC1#eta^{0} on n"); CC, numubar n --> mu- p eta resonant processes involving more than a single pion 71 NUANCE -> NEUT -43 ModeStack[43]->SetTitle("NC1#eta^{0} on p"); NC, numubar p --> numubar p eta resonant processes involving more than a single pion 72 NUANCE -> NEUT -42 ModeStack[42]->SetTitle("NC1#eta^{0} on n"); NC, numubar n --> numubar n eta resonant processes involving more than a single pion 73 NUANCE -> NEUT 21 ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); CC, numu n --> mu- K+ Lambda resonant processes involving more than a single pion 74 NUANCE -> NEUT 41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numu p --> numu K+ Lambda resonant processes involving more than a single pion 75 NUANCE -> NEUT 41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numu n --> numu K0 Lambda resonant processes involving more than a single pion 76 NUANCE -> NEUT -21 ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); CC, numubar n --> mu- K+ Lambda resonant processes involving more than a single pion 77 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar K+ Lambda resonant processes involving more than a single pion 78 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar K0 Lambda resonant processes involving more than a single pion CC Multipi ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC Multipi ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); 79 NUANCE -> NEUT 21 CC, numu n --> mu- p pi+ pi- two pion production 80 NUANCE -> NEUT 21 CC, numu n --> mu- p pi0 pi0 two pion production 81 NUANCE -> NEUT 41 NC, numu p --> numu p pi+ pi- two pion production 82 NUANCE -> NEUT 41 NC, numu p --> numu p pi0 pi0 two pion production 83 NUANCE -> NEUT 41 NC, numu n --> numu n pi+ pi- two pion production 84 NUANCE -> NEUT 41 NC, numu n --> numu n pi0 pi0 two pion production 85 NUANCE -> NEUT -21 CC, numubar n --> mu- p pi+ pi- two pion production 86 NUANCE -> NEUT -21 CC, numubar n --> mu- p pi0 pi0 two pion production 87 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar p pi+ pi- two pion production 88 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar p pi0 pi0 two pion production 89 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar n pi+ pi- two pion production 90 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar n pi0 pi0 two pion production 91 NUANCE -> NEUT 26 ModeStack[26]->SetTitle("DIS (W > 2.0)"); CC, numu N --> mu- X (where N=n,p) deep inelastic scattering (nu or nubar) 92 NUANCE -> NEUT 46 ModeStack[46]->SetTitle("DIS (W > 2.0)"); NC, numu N --> numu X (where N=n,p) deep inelastic scattering (nu or nubar) 93 NUANCE -> NEUT 17 1#gamma from #Delta: #nu_{l} n #rightarrow l^{-} p #gamma CC, numu n --> mu- p gamma -Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and higher) +Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and +higher) 94 NUANCE -> NEUT 39 1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma -neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; -neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; +neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma +from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; +neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma +from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; NC, numu N --> numu N gamma -Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and higher) +Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and +higher) 95 -> UNKOWN NEUT MODE -CC, numubar p --> mu+ Lambda, numubar n -- > mu+ Sigma-, numubar p --> mu+ Sigma0 +CC, numubar p --> mu+ Lambda, numubar n -- > mu+ Sigma-, numubar p --> mu+ +Sigma0 Cabibbo-suppressed QE hyperon production from nucleons 96 NUANCE -> NEUT 36 -neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; +neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC +coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; NC, numu A --> numu pi0 A coherent or diffractive pi0 production 97 NUANCE -> NEUT 16 -neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; +neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC +coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; CC, numu A --> mu- pi+ A (or numubar A --> coherent or diffractive pi0 production 98 -> UNKNOWN NEUT MODE NC, numu e- --> numu e- (or numubar e- --> neutrino + electron elastic scattering 99 -> UNKNOWN NEUT MODE CC, numu e- --> mu- nue neutrino + electron inverse muon decay NEUT Modes: // CC Modes - neutModeID[0] = 1; neutModeName[0] = "ccqe"; neutModeTitle[0] = "CCQE: #nu_{l} n #rightarrow l^{-} p"; - neutModeID[1] = 11; neutModeName[1] = "ccppip"; neutModeTitle[1] = "CC 1#pi: #nu_{l} p #rightarrow l^{-} p #pi^{+}"; - neutModeID[2] = 12; neutModeName[2] = "ccppi0"; neutModeTitle[2] = "CC 1#pi: #nu_{l} n #rightarrow l^{-} p #pi^{0}"; - neutModeID[3] = 13; neutModeName[3] = "ccnpip"; neutModeTitle[3] = "CC 1#pi: #nu_{l} n #rightarrow l^{-} n #pi^{+}"; - neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; - neutModeID[5] = 17; neutModeName[5] = "ccgam"; neutModeTitle[5] = "1#gamma from #Delta: #nu_{l} n #rightarrow l^{-} p #gamma"; - neutModeID[6] = 21; neutModeName[6] = "ccmpi"; neutModeTitle[6] = "CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi"; - neutModeID[7] = 22; neutModeName[7] = "cceta"; neutModeTitle[7] = "CC 1#eta: #nu_{l} n #rightarrow l^{-} p #eta"; - neutModeID[8] = 23; neutModeName[8] = "cck"; neutModeTitle[8] = "CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+}"; - neutModeID[9] = 26; neutModeName[9] = "ccdis"; neutModeTitle[9] = "CC DIS (2 GeV < W): #nu_{l} N #rightarrow l^{-} N' mesons"; - -neutModeID[10] = 31; neutModeName[10] = "ncnpi0"; neutModeTitle[10] = "NC 1#pi: #nu_{l} n #rightarrow #nu_{l} n #pi^{0}"; -neutModeID[11] = 32; neutModeName[11] = "ncppi0"; neutModeTitle[11] = "NC 1#pi: #nu_{l} p #rightarrow #nu_{l} p #pi^{0}"; -neutModeID[12] = 33; neutModeName[12] = "ncppim"; neutModeTitle[12] = "NC 1#pi: #nu_{l} n #rightarrow #nu_{l} p #pi^{-}"; -neutModeID[13] = 34; neutModeName[13] = "ncnpip"; neutModeTitle[13] = "NC 1#pi: #nu_{l} p #rightarrow #nu_{l} n #pi^{+}"; - -neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; -neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; -neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; - -neutModeID[17] = 41; neutModeName[17] = "ncmpi"; neutModeTitle[17] = "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi"; - -neutModeID[18] = 42; neutModeName[18] = "ncneta"; neutModeTitle[18] = "NC 1#eta: #nu_{l} n #rightarrow #nu_{l} n #eta"; -neutModeID[19] = 43; neutModeName[19] = "ncpeta"; neutModeTitle[19] = "NC 1#eta: #nu_{l} p #rightarrow #nu_{l} p #eta"; - -neutModeID[20] = 44; neutModeName[20] = "nck0"; neutModeTitle[20] = "NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0}"; -neutModeID[21] = 45; neutModeName[21] = "nckp"; neutModeTitle[21] = "NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+}"; - -neutModeID[22] = 46; neutModeName[22] = "ncdis"; neutModeTitle[22] = "NC DIS (2 GeV < W): #nu_{l} N #rightarrow #nu_{l} N' mesons"; - -neutModeID[23] = 51; neutModeName[23] = "ncqep"; neutModeTitle[23] = "NC elastic: #nu_{l} p #rightarrow #nu_{l} p"; -neutModeID[24] = 52; neutModeName[24] = "ncqen"; neutModeTitle[24] = "NC elastic: #nu_{l} n #rightarrow #nu_{l} n"; + neutModeID[0] = 1; neutModeName[0] = "ccqe"; neutModeTitle[0] = "CCQE: +#nu_{l} n #rightarrow l^{-} p"; + neutModeID[1] = 11; neutModeName[1] = "ccppip"; neutModeTitle[1] = "CC 1#pi: +#nu_{l} p #rightarrow l^{-} p #pi^{+}"; + neutModeID[2] = 12; neutModeName[2] = "ccppi0"; neutModeTitle[2] = "CC 1#pi: +#nu_{l} n #rightarrow l^{-} p #pi^{0}"; + neutModeID[3] = 13; neutModeName[3] = "ccnpip"; neutModeTitle[3] = "CC 1#pi: +#nu_{l} n #rightarrow l^{-} n #pi^{+}"; + neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC +coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; + neutModeID[5] = 17; neutModeName[5] = "ccgam"; neutModeTitle[5] = "1#gamma +from #Delta: #nu_{l} n #rightarrow l^{-} p #gamma"; + neutModeID[6] = 21; neutModeName[6] = "ccmpi"; neutModeTitle[6] = "CC (1.3 +< W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi"; + neutModeID[7] = 22; neutModeName[7] = "cceta"; neutModeTitle[7] = "CC +1#eta: #nu_{l} n #rightarrow l^{-} p #eta"; + neutModeID[8] = 23; neutModeName[8] = "cck"; neutModeTitle[8] = "CC 1K: +#nu_{l} n #rightarrow l^{-} #Lambda K^{+}"; + neutModeID[9] = 26; neutModeName[9] = "ccdis"; neutModeTitle[9] = "CC DIS +(2 GeV < W): #nu_{l} N #rightarrow l^{-} N' mesons"; + +neutModeID[10] = 31; neutModeName[10] = "ncnpi0"; neutModeTitle[10] = "NC 1#pi: +#nu_{l} n #rightarrow #nu_{l} n #pi^{0}"; +neutModeID[11] = 32; neutModeName[11] = "ncppi0"; neutModeTitle[11] = "NC 1#pi: +#nu_{l} p #rightarrow #nu_{l} p #pi^{0}"; +neutModeID[12] = 33; neutModeName[12] = "ncppim"; neutModeTitle[12] = "NC 1#pi: +#nu_{l} n #rightarrow #nu_{l} p #pi^{-}"; +neutModeID[13] = 34; neutModeName[13] = "ncnpip"; neutModeTitle[13] = "NC 1#pi: +#nu_{l} p #rightarrow #nu_{l} n #pi^{+}"; + +neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC +coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; +neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma +from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; +neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma +from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; + +neutModeID[17] = 41; neutModeName[17] = "ncmpi"; neutModeTitle[17] = "NC (1.3 +< W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi"; + +neutModeID[18] = 42; neutModeName[18] = "ncneta"; neutModeTitle[18] = "NC +1#eta: #nu_{l} n #rightarrow #nu_{l} n #eta"; +neutModeID[19] = 43; neutModeName[19] = "ncpeta"; neutModeTitle[19] = "NC +1#eta: #nu_{l} p #rightarrow #nu_{l} p #eta"; + +neutModeID[20] = 44; neutModeName[20] = "nck0"; neutModeTitle[20] = "NC 1K: +#nu_{l} n #rightarrow #nu_{l} #Lambda K^{0}"; +neutModeID[21] = 45; neutModeName[21] = "nckp"; neutModeTitle[21] = "NC 1K: +#nu_{l} n #rightarrow #nu_{l} #Lambda K^{+}"; + +neutModeID[22] = 46; neutModeName[22] = "ncdis"; neutModeTitle[22] = "NC DIS +(2 GeV < W): #nu_{l} N #rightarrow #nu_{l} N' mesons"; + +neutModeID[23] = 51; neutModeName[23] = "ncqep"; neutModeTitle[23] = "NC +elastic: #nu_{l} p #rightarrow #nu_{l} p"; +neutModeID[24] = 52; neutModeName[24] = "ncqen"; neutModeTitle[24] = "NC +elastic: #nu_{l} n #rightarrow #nu_{l} n"; */ diff --git a/src/FitBase/InputHandler.cxx b/src/FitBase/InputHandler.cxx index 86822e8..dfc38f0 100644 --- a/src/FitBase/InputHandler.cxx +++ b/src/FitBase/InputHandler.cxx @@ -1,1413 +1,1413 @@ // 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 <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "InputHandler.h" #include <csignal> //**************************************************************************** InputHandler::InputHandler(std::string const& handle, InputUtils::InputType inpType, std::string const& inputs) { //**************************************************************************** LOG(SAM) << "Creating InputHandler for " << handle << "..." << std::endl; LOG(SAM) << " -> [" << inputs << "]" << std::endl; // Initial Setup fMaxEvents = FitPar::Config().GetParI("input.maxevents"); fIsExplicitJointInput = (inpType == InputUtils::kJOINT_Input); fIsJointInput = fIsExplicitJointInput || InputUtils::IsJointInput(inputs); fInputType = inpType; fEvent = new FitEvent(); fSignalEvent = new BaseFitEvt(); fInput = inputs; fInputFile = InputUtils::ExpandInputDirectories(inputs); fName = handle; LOG(SAM) << " -> Type = " << fInputType << (fIsJointInput ? " (Composite)" : "") << std::endl; LOG(SAM) << " -> Input = " << fInputFile << std::endl; // Automatically check what sort of event file it is if (fIsJointInput) { ReadJointFile(); } else { fInputRootFile = new TFile(fInputFile.c_str(), "READ"); switch (fInputType) { // Setup the handler for each type case InputUtils::kNEUT_Input: { ReadNeutFile(); break; } case InputUtils::kNUWRO_Input: { ReadNuWroFile(); break; } case InputUtils::kGENIE_Input: { ReadGenieFile(); break; } case InputUtils::kGiBUU_Input: { ReadGiBUUFile(); break; } case InputUtils::kHIST_Input: { ReadHistogramFile(); break; } case InputUtils::kBNSPLN_Input: { ReadBinSplineFile(); break; } case InputUtils::kEVSPLN_Input: { ReadEventSplineFile(); break; } case InputUtils::kNUANCE_Input: { ReadNuanceFile(); break; } case InputUtils::kEMPTY_Input: { ReadEmptyEvents(); // For Validation break; } case InputUtils::kFEVENT_Input: { ReadFitEvents(); break; } default: { LOG(FTL) << " -> ERROR: Invalid Event File Type" << std::endl; fInputRootFile->ls(); throw; } } } // Setup MaxEvents After setup of ttree if (fMaxEvents > 1 && fMaxEvents < fNEvents) { LOG(SAM) << " -> Reading only " << fMaxEvents << " events from total." << std::endl; fNEvents = fMaxEvents; } fFluxList.push_back(fFluxHist); fEventList.push_back(this->fEventHist); fXSecList.push_back(this->fXSecHist); LOG(SAM) << " -> Finished handler initialisation." << std::endl; return; }; //******************************************************************** bool InputHandler::CanIGoFast() { //******************************************************************** if (fEventType == 6) { return true; } return false; } //******************************************************************** void InputHandler::ReadFitEvents() { //******************************************************************** fEventType = kINPUTFITEVENT; fFluxHist = (TH1D*)fInputRootFile->Get("nuisance_fluxhist"); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get("nuisance_eventhist"); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); tn = new TChain("nuisance_events", ""); tn->Add(Form("%s/nuisance_events", fInputFile.c_str())); // Assign nvect fNEvents = tn->GetEntries(); fEvent->SetBranchAddress(tn); // Print out what was read in LOG(SAM) << " -> Successfully Read FEvent file" << std::endl; return; } //******************************************************************** void InputHandler::ReadEmptyEvents() { //******************************************************************** fEventType = kEMPTY; // Set flux histograms to empty fFluxHist = new TH1D((fName + "_FLUX").c_str(), (fName + "_FLUX;E_{#nu};Flux").c_str(), 1, 0.0, 1.0); fFluxHist->SetBinContent(1, 1); // Set Event Hist to empty fEventHist = new TH1D((fName + "_EVT").c_str(), (fName + "_EVT;E_{#nu};Flux").c_str(), 1, 0.0, 1.0); fEventHist->SetBinContent(1, 1); // Set XSec hist to empty fXSecHist = new TH1D((fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu};XSec").c_str(), 1, 0.0, 1.0); fXSecHist->SetBinContent(1, 1); fNEvents = 0; } //******************************************************************** void InputHandler::ReadEventSplineFile() { //******************************************************************** LOG(SAM) << " -> Setting up SPLINE inputs" << std::endl; // Event Type 7 SPLINES fEventType = 6; fFluxHist = (TH1D*)fInputRootFile->Get("FitFluxHist"); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get("FitEventHist"); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); tn = new TChain("FitEvents", ""); tn->Add(Form("%s/FitEvents", fInputFile.c_str())); // Setup Spline Stuff fSplineHead = new FitSplineHead(fInputRootFile, "FitSplineHead"); // Assign nvect fNEvents = tn->GetEntries(); fEvent->SetBranchAddress(tn); fEvent->SetSplineCoeffAddress(tn); fEvent->SetType(kEVTSPLINE); // Print out what was read in LOG(SAM) << " -> Successfully Read FEvent file" << std::endl; // Load Dial Coeffs into vector tn->GetEntry(0); int ncoeff = fEvent->GetNCoeff(); fSplineArray = new double*[fNEvents]; for (int i = 0; i < fNEvents; i++) { tn->GetEntry(i); // Copy Splines over fSplineArray[i] = new double[ncoeff]; for (int j = 0; j < fEvent->GetNCoeff(); j++) { fSplineArray[i][j] = fEvent->GetCoeff(j); } } LOG(DEB) << "Loaded all spline coeffs" << endl; // Set input.maxevents CALC Here before we load in splines if (fMaxEvents > 1 and fMaxEvents < fNEvents) { LOG(SAM) << " -> Reading only " << fMaxEvents << " events from total spline events." << std::endl; fNEvents = fMaxEvents; } // Print out what was read in LOG(SAM) << " -> Successfully Read SPLINE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); int cnt = 1; std::list<FitSpline*>::iterator spl_iter = this->fSplineHead->SplineObjects.begin(); for (; spl_iter != this->fSplineHead->SplineObjects.end(); spl_iter++) { FitSpline* spl = (*spl_iter); LOG(SAM) << " -> Spline " << cnt << ". " << spl->id << " " << spl->form << " " << "NDIM(" << spl->ndim << ") " << "NPAR(" << spl->npar << ") " << "PTS(" << spl->points << ") " << std::endl; cnt++; } } //******************************************************************** FitSplineHead* InputHandler::GetSplineHead() { //******************************************************************** return fSplineHead; } //******************************************************************** void InputHandler::SetupCache() { //******************************************************************** tn->SetCacheSize(FitPar::Config().GetParI("cachesize")); tn->AddBranchToCache("*", kTRUE); tn->StopCacheLearningPhase(); } //******************************************************************** void InputHandler::ReadJointFile() { //******************************************************************** std::vector<std::string> inputs; if (fIsExplicitJointInput) { // Included for backwards compatibility. std::string line; std::ifstream card(fInputFile.c_str(), ifstream::in); LOG(FIT) << "Parsing input card: \'" << fInputFile << "\'" << endl; while (std::getline(card >> std::ws, line, '\n')) { if (line.empty()) { continue; } std::vector<std::string> file_descriptor = GeneralUtils::ParseToStr(line, ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "Found JOINT card file line: \"" << line << "\", expected \"INPUTTYPE:File.root\"." << std::endl; throw; } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); if (!inputs.size()) { fInputType = inpType; LOG(SAM) << " -> InputHandler type: " << fInputType << std::endl; } else if (inpType != fInputType) { ERR(FTL) << "First input type in JOINT card was: " << fInputType << " but found: " << inpType << ", all files in a JOINT must be the same." << std::endl; throw; } LOG(SAM) << "\t -> Found input file: " << file_descriptor[1] << std::endl; inputs.push_back(file_descriptor[1]); } } else { LOG(SAM) << " -> Parsing list of inputs for composite input." << std::endl; inputs = GeneralUtils::ParseToStr(fInputFile, ","); inputs.front() = inputs.front().substr(1); inputs.back() = inputs.back().substr(0, inputs.back().size() - 1); for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { LOG(SAM) << "\t -> Found input file: " << inputs[inp_it] << std::endl; } } // Loop over input and get the flux files // Using a temporary input handler to do this, which is a bit dodge. int count_low = 0; int temp_EventType = kUNKNOWN; for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { LOG(SAM) << "Creating temporary handler to read file: " << inputs.at(inp_it) << endl; // Create Temporary InputHandlers inside InputHandler temp_input(std::string(Form("temp_input_%li", inp_it)), fInputType, inputs.at(inp_it)); if (temp_EventType != temp_input.GetType() and inp_it > 0) { ERR(FTL) << "Can't use joint events with mismatched trees!" << std::endl; ERR(FTL) << "This should not have happened. Please report this as a bug " "along with your input card file." << std::endl; throw; } LOG(FIT) << "Getting objects from " << temp_input.fInputFile << endl; temp_EventType = temp_input.GetType(); TH1D* temp_flux = (TH1D*)temp_input.GetFluxHistogram()->Clone(); TH1D* temp_evts = (TH1D*)temp_input.GetEventHistogram()->Clone(); TH1D* temp_xsec = (TH1D*)temp_input.GetXSecHistogram()->Clone(); int temp_events = temp_input.GetNEvents(); temp_flux->SetName( (fName + "_" + temp_input.GetInputStateString() + "_FLUX").c_str()); temp_evts->SetName( (fName + "_" + temp_input.GetInputStateString() + "_EVT").c_str()); temp_xsec->SetName( (fName + "_" + temp_input.GetInputStateString() + "_XSEC").c_str()); fFluxList.push_back(temp_flux); fEventList.push_back(temp_evts); fXSecList.push_back(temp_xsec); fJointIndexLow.push_back(count_low); fJointIndexHigh.push_back(count_low + temp_events); fJointIndexHist.push_back((TH1D*)temp_evts->Clone()); count_low += temp_events; LOG(FIT) << "Temp input has " << temp_events << " events." << endl; if (inp_it == 0) { fFluxHist = (TH1D*)temp_flux->Clone(); fEventHist = (TH1D*)temp_evts->Clone(); } else { fFluxHist->Add(temp_flux); fEventHist->Add(temp_evts); } LOG(SAM) << "Added Input File " << inputs.at(inp_it) << std::endl << " which contained " << temp_events << " events." << std::endl; } // Now have all correctly normalised histograms all we need to do is setup the // TChains // Input Assumes all the same type std::string tree_name = ""; if (temp_EventType == kNEUT) { tree_name = "neuttree"; } else if (temp_EventType == kNUWRO) { tree_name = "treeout"; } else if (temp_EventType == kGENIE) { tree_name = "gtree"; } // Add up the TChains tn = new TChain(tree_name.c_str()); for (UInt_t i = 0; i < inputs.size(); i++) { // PARSE INPUT LOG(DEB) << "Adding new tchain " << inputs.at(i) << std::endl; tn->Add(inputs.at(i).c_str()); } // Setup Events fNEvents = tn->GetEntries(); if (temp_EventType == kNEUT) { #ifdef __NEUT_ENABLED__ fEventType = kNEUT; fNeutVect = NULL; tn->SetBranchAddress("vectorbranch", &fNeutVect); fEvent->SetEventAddress(&fNeutVect); #endif } else if (temp_EventType == kNUWRO) { #ifdef __NUWRO_ENABLED__ fEventType = kNUWRO; fNuwroEvent = NULL; tn->SetBranchAddress("e", &fNuwroEvent); fEvent->SetEventAddress(&fNuwroEvent); #endif } else if (temp_EventType == kGENIE) { #ifdef __GENIE_ENABLED__ fEventType = kGENIE; fGenieGHep = NULL; fGenieNtpl = NULL; tn->SetBranchAddress("gmcrec", &fGenieNtpl); fEvent->SetEventAddress(&fGenieNtpl); #endif } // Normalise event histogram PDFS for weights for (UInt_t i = 0; i < inputs.size(); i++) { TH1D* temp_hist = (TH1D*)fJointIndexHist.at(i)->Clone(); fJointIndexScale.push_back( double(fNEvents) / fEventHist->Integral("width") * fJointIndexHist.at(i)->Integral("width") / double(fJointIndexHigh.at(i) - fJointIndexLow.at(i))); temp_hist->Scale(double(fNEvents) / fEventHist->Integral("width")); temp_hist->Scale(fJointIndexHist.at(i)->Integral("width") / double(fJointIndexHigh.at(i))); fJointIndexHist.at(i) = temp_hist; } fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); return; } //******************************************************************** void InputHandler::ReadNeutFile() { //******************************************************************** #ifdef __NEUT_ENABLED__ LOG(SAM) << " -> Setting up NEUT inputs" << std::endl; // Event Type 0 Neut fEventType = kNEUT; // Get flux histograms NEUT supplies fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "flux")).c_str()); if (!fFluxHist) { ERR(FTL) << "No Flux Hist in NEUT ROOT file." << std::endl; throw; } fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "evtrt")).c_str()); if (!fEventHist) { ERR(FTL) << "No Event Hist in NEUT ROOT file." << std::endl; throw; } fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); // Read in the file once only tn = new TChain("neuttree", ""); tn->Add(Form("%s/neuttree", fInputFile.c_str())); // Assign nvect fNEvents = tn->GetEntries(); fNeutVect = NULL; tn->SetBranchAddress("vectorbranch", &fNeutVect); // Make the custom event read in nvect when calling CalcKinematics fEvent->SetEventAddress(&fNeutVect); // Print out what was read in LOG(SAM) << " -> Successfully Read NEUT file" << std::endl; if (LOG_LEVEL(SAM)) { PrintStartInput(); } #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NEUT Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-neut or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadNuWroFile() { //******************************************************************** #ifdef __NUWRO_ENABLED__ LOG(SAM) << " -> Setting up Nuwro inputs" << std::endl; // Event Type 1 == NuWro fEventType = kNUWRO; // Setup the TChain for nuwro event tree tn = new TChain("treeout"); tn->AddFile(fInputFile.c_str()); // Get entries and fNuwroEvent fNEvents = tn->GetEntries(); fNuwroEvent = NULL; tn->SetBranchAddress("e", &fNuwroEvent); fEvent->SetEventAddress(&fNuwroEvent); // Check if we have saved an xsec histogram before fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "FluxHist")).c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "EvtHist")).c_str()); // Check if we are forcing plot generation (takes time) bool regenFlux = FitPar::Config().GetParB("input.regen_nuwro_plots"); if (regenFlux) LOG(SAM) << " -> Forcing NuWro XSec/Flux plots to be generated at the start. " << std::endl; // Already generated flux and event histograms if (fFluxHist and fEventHist and !regenFlux) { fXSecHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "xsec")).c_str()); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); // Need to regenerate if not found } else { LOG(SAM) << " -> No NuWro XSec or Flux Histograms found, need to regenerate!" << std::endl; // Can grab flux histogram from the pars tn->GetEntry(0); int beamtype = fNuwroEvent->par.beam_type; if (beamtype == 0) { std::string fluxstring = fNuwroEvent->par.beam_energy; std::vector<double> fluxvals = GeneralUtils::ParseToDbl(fluxstring, " "); int pdg = fNuwroEvent->par.beam_particle; double Elow = double(fluxvals[0]) / 1000.0; double Ehigh = double(fluxvals[1]) / 1000.0; LOG(SAM) << " - Adding new nuwro flux " << "pdg: " << pdg << "Elow: " << Elow << "Ehigh: " << Ehigh << std::endl; fFluxHist = new TH1D("fluxplot", "fluxplot", fluxvals.size() - 2, Elow, Ehigh); for (UInt_t j = 2; j < fluxvals.size(); j++) { LOG(DEB) << "Flux bin:" << j << " = " << fluxvals[j] << endl; fFluxHist->SetBinContent(j - 1, fluxvals[j]); } } else if (beamtype == 1) { std::string fluxstring = fNuwroEvent->par.beam_content; std::vector<std::string> fluxlines = GeneralUtils::ParseToStr(fluxstring, "\n"); for (UInt_t i = 0; i < fluxlines.size(); i++) { std::vector<double> fluxvals = GeneralUtils::ParseToDbl(fluxlines[i], " "); int pdg = int(fluxvals[0]); double pctg = double(fluxvals[1]) / 100.0; double Elow = double(fluxvals[2]) / 1000.0; double Ehigh = double(fluxvals[3]) / 1000.0; LOG(DEB) << " - Adding new nuwro flux " << "pdg: " << pdg << "pctg: " << pctg << "Elow: " << Elow << "Ehigh: " << Ehigh << std::endl; TH1D* fluxplot = new TH1D("fluxplot", "fluxplot", fluxvals.size() - 4, Elow, Ehigh); for (UInt_t j = 4; j < fluxvals.size(); j++) { fluxplot->SetBinContent(j + 1, fluxvals[j]); } if (fFluxHist) fFluxHist->Add(fluxplot); else fFluxHist = (TH1D*)fluxplot->Clone(); } } fFluxHist->SetNameTitle("nuwro_flux", "nuwro_flux;E_{#nu} (GeV); Flux"); fEventHist = (TH1D*)fFluxHist->Clone(); fEventHist->Reset(); fEventHist->SetNameTitle("nuwro_evt", "nuwro_evt"); fXSecHist = (TH1D*)fFluxHist->Clone(); fXSecHist->Reset(); fXSecHist->SetNameTitle("nuwro_xsec", "nuwro_xsec"); // Start Processing LOG(SAM) << " -> Processing NuWro Input Flux for " << fNEvents << " events (This can take a while...) " << std::endl; double Enu = 0.0; double TotXSec = 0.0; double totaleventmode = 0.0; double totalevents = 0.0; // --- loop for (int i = 0; i < fNEvents; i++) { tn->GetEntry(i); if (i % 100000 == 0) LOG(SAM) << " i " << i << std::endl; // Get Variables - Enu = fNuwroEvent->in[0].E() / 1000.0; + Enu = fNuwroEvent->in[0].t / 1000.0; TotXSec = fNuwroEvent->weight; // Fill a flux and xsec histogram fEventHist->Fill(Enu); fXSecHist->Fill(Enu, TotXSec); // Keep Tally totaleventmode += TotXSec; totalevents++; } LOG(SAM) << " -> Flux Processing Loop Finished." << std::endl; if (fEventHist->Integral() == 0.0) { ERR(FTL) << "NO EVENTS FOUND IN RANGE! " << std::endl; exit(-1); } // Sort out plot scaling double AvgXSec = (totaleventmode * 1.0E38 / (totalevents + 0.)); LOG(SAM) << " -> Average XSec = " << AvgXSec << std::endl; fEventHist->Scale(1.0 / fEventHist->Integral()); // Convert to PDF fEventHist->Scale(fFluxHist->Integral() * AvgXSec); // Convert to Proper Event Rate fXSecHist->Add(fEventHist); // Get Event Rate Plot fXSecHist->Divide(fFluxHist); // Make XSec Plot // fEventHist = (TH1D*)fFluxHist->Clone(); // fEventHist->Multiply(fXSecHist); // Clear over/underflows incase they mess with integrals later. fFluxHist->SetBinContent(0, 0.0); fFluxHist->SetBinContent(fFluxHist->GetNbinsX() + 2, 0.0); fEventHist->SetBinContent(0, 0.0); fEventHist->SetBinContent(fEventHist->GetNbinsX() + 2, 0.0); LOG(SAM) << " -> Finished making NuWro event plots. Saving them for next time..." << std::endl; TFile* temp_save_file = new TFile(fInputFile.c_str(), "UPDATE"); temp_save_file->cd(); fFluxHist->Write("FluxHist", TObject::kOverwrite); fEventHist->Write("EventHist", TObject::kOverwrite); fXSecHist->Write("XSecHist", TObject::kOverwrite); temp_save_file->ls(); temp_save_file->Close(); delete temp_save_file; fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); } // end regenerate histos // Print out what was read in LOG(SAM) << " -> Successfully Read NUWRO file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NuWro Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-nuwro or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadGenieFile() { //******************************************************************** #ifdef __GENIE_ENABLED__ // Event Type 5 GENIE fEventType = kGENIE; // Open Root File LOG(SAM) << "Reading event file " << fInputFile << std::endl; // Get flux histograms NEUT supplies fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_flux")).c_str()); if (!fFluxHist) { ERR(FTL) << "GENIE FILE doesn't contain flux/xsec info" << std::endl; ERR(FTL) << "Run app/PrepareGENIE first" << std::endl; throw; } fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_events")) .c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_xsec")).c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); // Setup the TChain for GENIE event tree tn = new TChain("gtree"); tn->AddFile(fInputFile.c_str()); fNEvents = tn->GetEntries(); StopTalking(); fGenieGHep = NULL; fGenieNtpl = NULL; // NtpMCEventRecord * fGenieNtpl = 0; tree->SetBranchAddress(gmrec, // &fGenieNtpl); tn->SetBranchAddress("gmcrec", &fGenieNtpl); // Make the custom event read in nvect when calling CalcKinematics fEvent->SetEventAddress(&fGenieNtpl); // Set Titles fEventHist->SetNameTitle( (fName + "_EVT").c_str(), (fName + "_EVT;E_{#nu} (GeV); Events (1#times10^{-38})").c_str()); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); StartTalking(); // Print out what was read in LOG(SAM) << " -> Successfully Read GENIE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "GENIE Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-genie or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadGiBUUFile() { //******************************************************************** #ifdef __GiBUU_ENABLED__ fEventType = kGiBUU; // Open Root File LOG(SAM) << "Opening event file " << fInputFile << std::endl; TFile* rootFile = new TFile(fInputFile.c_str(), "READ"); // Get flux histograms NEUT supplies TH1D* numuFlux = dynamic_cast<TH1D*>(rootFile->Get("numu_flux")); TH1D* numubFlux = dynamic_cast<TH1D*>(rootFile->Get("numub_flux")); TH1D* nueFlux = dynamic_cast<TH1D*>(rootFile->Get("nue_flux")); TH1D* nuebFlux = dynamic_cast<TH1D*>(rootFile->Get("nueb_flux")); // Replace local pointers with NULL dir'd clones. if (numuFlux) { numuFlux = static_cast<TH1D*>(numuFlux->Clone()); numuFlux->Scale(1.0 / numuFlux->Integral("width")); std::cout << "GiBUU Flux: numuFlux, Width integral = " << numuFlux->Integral("width") << std::endl; numuFlux->SetDirectory(NULL); numuFlux->SetNameTitle( (fName + "_numu_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str()); fFluxList.push_back(numuFlux); } if (numubFlux) { numubFlux = static_cast<TH1D*>(numubFlux->Clone()); numubFlux->Scale(1.0 / numubFlux->Integral("width")); std::cout << "GiBUU Flux: numubFlux, Width integral = " << numubFlux->Integral("width") << std::endl; numubFlux->SetDirectory(NULL); numubFlux->SetNameTitle( (fName + "_numub_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)").c_str()); fFluxList.push_back(numubFlux); } if (nueFlux) { nueFlux = static_cast<TH1D*>(nueFlux->Clone()); nueFlux->Scale(1.0 / nueFlux->Integral("width")); std::cout << "GiBUU Flux: nueFlux, Width integral = " << nueFlux->Integral("width") << std::endl; nueFlux->SetDirectory(NULL); nueFlux->SetNameTitle( (fName + "_nue_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str()); fFluxList.push_back(nueFlux); } if (nuebFlux) { nuebFlux = static_cast<TH1D*>(nuebFlux->Clone()); nuebFlux->Scale(1.0 / nuebFlux->Integral("width")); std::cout << "GiBUU Flux: nuebFlux, Width integral = " << nuebFlux->Integral("width") << std::endl; nuebFlux->SetDirectory(NULL); nuebFlux->SetNameTitle( (fName + "_nueb_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)").c_str()); fFluxList.push_back(nuebFlux); } rootFile->Close(); tn = new TChain("giRooTracker"); tn->AddFile(fInputFile.c_str()); GiBUUStdHepReader* giRead = new GiBUUStdHepReader(); giRead->SetBranchAddresses(tn); fEvent->SetEventAddress(giRead); bool IsNuBarDominant = false; size_t Found_nu = 0; size_t Found_nuMask = ((numuFlux ? 1 : 0) + (numubFlux ? 2 : 0) + (nueFlux ? 4 : 0) + (nuebFlux ? 8 : 0)); static const char* specNames[] = {"numu", "numubar", "nue", "nuebar"}; size_t nExpected = (Found_nuMask & (1 << 0)) + (Found_nuMask & (1 << 1)) + (Found_nuMask & (1 << 2)) + (Found_nuMask & (1 << 3)); size_t nFound = 0; std::string expectStr = ""; for (size_t sn_it = 0; sn_it < 4; ++sn_it) { if (Found_nuMask & (1 << sn_it)) { if (!nFound) { expectStr = "("; } expectStr += specNames[sn_it]; nFound++; if (nFound == nExpected) { expectStr += ")"; } else { expectStr += ", "; } } } LOG(SAM) << "Looking for dominant vector species in GiBUU file (" << fInputFile << ") expecting to find: " << expectStr << std::endl; size_t maskHW = GeneralUtils::GetHammingWeight(Found_nuMask); if (maskHW > 2) { LOG(SAM) << "We are looking for more than two species... this will have to " "loop through a large portion of the vector. Please be patient." << std::endl; } double SpeciesWeights[] = {0, 0, 0, 0}; Long64_t nevt = 0; fNEvents = tn->GetEntries(); fFluxHist = NULL; while ((Found_nu != Found_nuMask) && (nevt < fNEvents)) { if ((maskHW == 2) && fFluxHist) { // If we have found the dominant one can // now guess the other size_t OtherBit = GeneralUtils::GetFirstOnBit(Found_nuMask - Found_nu); SpeciesWeights[OtherBit] = 1 - giRead->SpeciesWght; Found_nu += (1 << OtherBit); LOG(SAM) << "\tGuessing other species weight as we are only expecting " "two species. Other species weight: " << SpeciesWeights[OtherBit] << std::endl; continue; } tn->GetEntry(nevt++); fEvent->CalcKinematics(); FitParticle* isnu = fEvent->GetHMISParticle(PhysConst::pdg_neutrinos); if (!isnu) { continue; } switch (isnu->fPID) { case 12: { if ((Found_nu & 4)) { continue; } Found_nu += 4; SpeciesWeights[2] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; if ((giRead->SpeciesWght < 0.5) && (maskHW > 1)) { // If we only care about a single species, then // species-weight might not be filled. continue; } fFluxHist = nueFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be nue dominated vector." << std::endl; break; } case -12: { if ((Found_nu & 8)) { continue; } Found_nu += 8; SpeciesWeights[3] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; if ((giRead->SpeciesWght < 0.5) && (maskHW > 1)) { // If we only care about a single species, then // species-weight might not be filled. continue; } IsNuBarDominant = true; fFluxHist = nuebFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be nuebar dominated vector." << std::endl; break; } case 14: { if ((Found_nu & 1)) { continue; } Found_nu += 1; SpeciesWeights[0] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; if ((giRead->SpeciesWght < 0.5) && (maskHW > 1)) { // If we only care about a single species, then // species-weight might not be filled. continue; } fFluxHist = numuFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be numu dominated vector." << std::endl; break; } case -14: { if ((Found_nu & 2)) { continue; } Found_nu += 2; SpeciesWeights[1] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; if ((giRead->SpeciesWght < 0.5) && (maskHW > 1)) { // If we only care about a single species, then // species-weight might not be filled. continue; } IsNuBarDominant = true; fFluxHist = numubFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be numubar dominated vector." << std::endl; break; } default: {} } } if (Found_nu != Found_nuMask) { ERR(FTL) << "Input GiBUU file (" << fInputFile << ") appeared to not contain all the relevant incoming neutrino " "species: Found (numu:" << ((Found_nu & (1 << 0)) ? 1 : 0) << ",numub:" << ((Found_nu & (1 << 1)) ? 1 : 0) << ",nue:" << ((Found_nu & (1 << 2)) ? 1 : 0) << ",nueb:" << ((Found_nu & (1 << 3)) ? 1 : 0) << "), expected: (numu:" << ((Found_nuMask & (1 << 0)) ? 1 : 0) << ",numub:" << ((Found_nuMask & (1 << 1)) ? 1 : 0) << ",nue:" << ((Found_nuMask & (1 << 2)) ? 1 : 0) << ",nueb:" << ((Found_nuMask & (1 << 3)) ? 1 : 0) << ")" << std::endl; throw; } if (!fFluxHist) { ERR(FTL) << "Couldn't find: " << (IsNuBarDominant ? "nuXb_flux" : "nuX_flux") << " in input file: " << fInputRootFile->GetName() << std::endl; throw; } if (numuFlux) { if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[0])) { numuFlux->Scale(SpeciesWeights[0]); } TH1D* numuEvt = static_cast<TH1D*>(numuFlux->Clone((fName + "_numu_EVT").c_str())); numuEvt->Reset(); numuEvt->SetBinContent(1, SpeciesWeights[0] * double(fNEvents) / numuEvt->GetXaxis()->GetBinWidth(1)); TH1D* numuXSec = static_cast<TH1D*>(numuEvt->Clone((fName + "_numu_XSEC").c_str())); numuXSec->Divide(fFluxHist); numuXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (numubFlux) { if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[1])) { numubFlux->Scale(SpeciesWeights[1]); } TH1D* numubEvt = static_cast<TH1D*>(numubFlux->Clone((fName + "_numub_EVT").c_str())); numubEvt->Reset(); numubEvt->SetBinContent(1, SpeciesWeights[1] * double(fNEvents) / numubEvt->GetXaxis()->GetBinWidth(1)); TH1D* numubXSec = static_cast<TH1D*>(numubEvt->Clone((fName + "_numub_XSEC").c_str())); numubXSec->Divide(fFluxHist); numubXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (nueFlux) { if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[2])) { nueFlux->Scale(SpeciesWeights[2]); } TH1D* nueEvt = static_cast<TH1D*>(nueFlux->Clone((fName + "_nue_EVT").c_str())); nueEvt->Reset(); nueEvt->SetBinContent(1, SpeciesWeights[2] * double(fNEvents) / nueEvt->GetXaxis()->GetBinWidth(1)); TH1D* nueXSec = static_cast<TH1D*>(nueEvt->Clone((fName + "_nue_XSEC").c_str())); nueXSec->Divide(fFluxHist); nueXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (nuebFlux) { if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[3])) { nuebFlux->Scale(SpeciesWeights[3]); } TH1D* nuebEvt = static_cast<TH1D*>(nuebFlux->Clone((fName + "_nueb_EVT").c_str())); nuebEvt->Reset(); nuebEvt->SetBinContent(1, SpeciesWeights[3] * double(fNEvents) / nuebEvt->GetXaxis()->GetBinWidth(1)); TH1D* nuebXSec = static_cast<TH1D*>(nuebEvt->Clone((fName + "_nueb_XSEC").c_str())); nuebXSec->Divide(fFluxHist); nuebXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } tn->GetEntry(0); LOG(SAM) << "\tInput GiBUU file species weights: (numu:" << SpeciesWeights[0] << ",numub:" << SpeciesWeights[1] << ",nue:" << SpeciesWeights[2] << ",nueb:" << SpeciesWeights[3] << ")" << std::endl; fFluxHist->SetNameTitle( (fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV);" + (IsNuBarDominant ? "#Phi_{#bar{#nu}} (A.U.)" : "#Phi_{#nu} (A.U.)")) .c_str()); fEventHist = static_cast<TH1D*>(fFluxHist->Clone((fName + "_EVT").c_str())); fEventHist->Reset(); fEventHist->SetBinContent(1, double(fNEvents) * TotalIntegratedFlux(0, 1.E5, "width") / fEventHist->GetXaxis()->GetBinWidth(1)); fXSecHist = static_cast<TH1D*>(fEventHist->Clone((fName + "_XSEC").c_str())); fXSecHist->Divide(fFluxHist); fXSecHist->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "GiBUU Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with -DUSE_GiBUU=1." << std::endl; exit(-1); #endif } //******************************************************************** void InputHandler::ReadBinSplineFile() { //******************************************************************** // Bin Splines are saved as one event for each histogram bin. // So just read in as normal event splines and it'll all get sorted easily. } //******************************************************************** void InputHandler::ReadHistogramFile() { //******************************************************************** // Convert the raw histogram into a series of events with X variables // So we don't have to pass stuff upsteam } //******************************************************************** void InputHandler::ReadNuanceFile() { //******************************************************************** #ifdef __NUANCE_ENABLED__ // Read in Nuance output ROOT file (converted from hbook) LOG(SAM) << " Reading NUANCE " << std::endl; fEventType = kNUANCE; // Read in NUANCE Tree tn = new TChain("h3"); tn->AddFile(fInputFile.c_str()); // Get entries and fNuwroEvent fNEvents = tn->GetEntries(); fNuanceEvt = new NuanceEvent(); // SetBranchAddress for Nuance // tn->SetBranchAddress("cc",&fNuanceEvt->cc); // tn->SetBranchAddress("bound",&fNuanceEvt->bound); tn->SetBranchAddress("neutrino", &fNuanceEvt->neutrino); tn->SetBranchAddress("target", &fNuanceEvt->target); tn->SetBranchAddress("channel", &fNuanceEvt->channel); // tn->SetBranchAddress("iniQ", &fNuanceEvt->iniQ); // tn->SetBranchAddress("finQ", &fNuanceEvt->finQ); // tn->SetBranchAddress("lepton0", &fNuanceEvt->lepton0); // tn->SetBranchAddress("polar", &fNuanceEvt->polar); // tn->SetBranchAddress("qsq", &fNuanceEvt->qsq); // tn->SetBranchAddress("w", &fNuanceEvt->w); // tn->SetBranchAddress("x",&fNuanceEvt->x); // tn->SetBranchAddress("y",&fNuanceEvt->y); tn->SetBranchAddress("p_neutrino", &fNuanceEvt->p_neutrino); tn->SetBranchAddress("p_targ", &fNuanceEvt->p_targ); // tn->SetBranchAddress("vertex", &fNuanceEvt->vertex); // tn->SetBranchAddress("start",&fNuanceEvt->start); // tn->SetBranchAddress("depth",&fNuanceEvt->depth); // tn->SetBranchAddress("flux",&fNuanceEvt->flux); tn->SetBranchAddress("n_leptons", &fNuanceEvt->n_leptons); tn->SetBranchAddress("p_ltot", &fNuanceEvt->p_ltot); tn->SetBranchAddress("lepton", &fNuanceEvt->lepton); tn->SetBranchAddress("p_lepton", &fNuanceEvt->p_lepton); tn->SetBranchAddress("n_hadrons", &fNuanceEvt->n_hadrons); tn->SetBranchAddress("p_htot", &fNuanceEvt->p_htot); tn->SetBranchAddress("hadron", &fNuanceEvt->hadron); tn->SetBranchAddress("p_hadron", &fNuanceEvt->p_hadron); fEvent->SetEventAddress(&fNuanceEvt); double EnuMin = 0.0; // tn->GetMinimum("p_neutrino[3]"); double EnuMax = 1000.0; // tn->GetMaximum("p_neutrino[3]"); fFluxHist = new TH1D((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str(), 100, EnuMin, EnuMax); for (int i = 0; i < fFluxHist->GetNbinsX(); i++) { fFluxHist->SetBinContent(i + 1, 1.0); } fFluxHist->Scale(1.0 / fFluxHist->Integral()); fEventHist = new TH1D((fName + "_EVT").c_str(), (fName + "_EVT").c_str(), 100, EnuMin, EnuMax); for (int i = 0; i < fFluxHist->GetNbinsX(); i++) { fEventHist->SetBinContent(i + 1, 1.0); } fEventHist->Scale(1.0 / fEventHist->Integral()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); // Print out what was read in LOG(SAM) << " -> Successfully Read NUANCE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NUANCE Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with -DUSE_NUANCE=1!" << std::endl; exit(-1); #endif } //******************************************************************** void InputHandler::PrintStartInput() { //******************************************************************** LOG(SAM) << " -> Total events = " << fNEvents << std::endl; LOG(SAM) << " -> Energy Range = " << fFluxHist->GetXaxis()->GetXmin() << "-" << fFluxHist->GetXaxis()->GetXmax() << " GeV" << std::endl; LOG(SAM) << " -> Integrated Flux Hist = " << fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width") << std::endl; LOG(SAM) << " -> Integrated Event Hist = " << fEventHist->Integral(0, fEventHist->GetNbinsX(), "width") << std::endl; LOG(SAM) << " -> Integrated Inclusive XSec = " << (fEventHist->Integral(0, fEventHist->GetNbinsX(), "width") / fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width")) * 1E-38 << std::endl; LOG(SAM) << " -> Integrated XSec Hist = " << fXSecHist->Integral("width") << endl; if (fEventType == kEVTSPLINE) return; // Get First event info StopTalking(); tn->GetEntry(0); StartTalking(); fEvent->CalcKinematics(); LOG(SAM) << " -> Event 0. Neutrino PDG = " << fEvent->PartInfo(0)->fPID << std::endl; LOG(SAM) << " Target A = " << fEvent->GetTargetA() << std::endl; LOG(SAM) << " Target Z = " << fEvent->GetTargetZ() << std::endl; } //******************************************************************** std::string InputHandler::GetInputStateString() { //******************************************************************** tn->GetEntry(0); fEvent->CalcKinematics(); std::ostringstream state; state << "T" << fEventType << "_PDG" << fEvent->PartInfo(0)->fPID << "_Z" << fEvent->GetTargetZ() << "_A" << fEvent->GetTargetA(); return state.str(); } //******************************************************************** void InputHandler::ReadEvent(unsigned int i) { //******************************************************************** bool using_events = (fEventType == kNEUT || fEventType == kGENIE || fEventType == kNUWRO || fEventType == kEVTSPLINE || fEventType == kNUANCE || fEventType == kGiBUU); if (using_events) { tn->LoadTree(i); tn->GetEntry(i); fEvent->CalcKinematics(); fEvent->Index = i; fEventIndex = i; fEvent->InputWeight = GetInputWeight(i); } else { GetTreeEntry(i); } } //******************************************************************** void InputHandler::GetTreeEntry(const Long64_t i) { //******************************************************************** // If we're just reading from the input root file if (fEventType != kEVTSPLINE) { tn->GetEntry(i); } else { fEvent->FillCoeff(fSplineArray[i]); } fEventIndex = i; fEvent->InputWeight = GetInputWeight(i); } //******************************************************************** double InputHandler::GetInputWeight(const int entry) { //******************************************************************** if (fEventType == kGiBUU) { return fEvent->InputWeight; } // if (fEventType == kGENIE) { // return fEvent->InputWeight; // } if (!fIsJointInput) { return 1.0; } double weight = 1.0; // Find Histogram for (UInt_t j = 0; j < fJointIndexLow.size(); j++) { if (entry >= fJointIndexLow.at(j) and entry < fJointIndexHigh.at(j)) { weight *= fJointIndexScale.at(j); break; } } return weight; } //******************************************************************** int InputHandler::GetGenEvents() { //******************************************************************** if (fEventType == 6) return fSplineHead->ngen_events; else return GetNEvents(); } //******************************************************************** double InputHandler::TotalIntegratedFlux(double low, double high, std::string intOpt) { //******************************************************************** Int_t minBin = fFluxHist->GetXaxis()->FindFixBin(low); Int_t maxBin = fFluxHist->GetXaxis()->FindFixBin(high); if ((fFluxHist->IsBinOverflow(minBin) && (low != -9999.9))) { minBin = 1; } if ((fFluxHist->IsBinOverflow(maxBin) && (high != -9999.9))) { maxBin = fFluxHist->GetXaxis()->GetNbins() + 1; } // If we are within a single bin if (minBin == maxBin) { // Get the contained fraction of the single bin's width return ((high - low) / fFluxHist->GetXaxis()->GetBinWidth(minBin)) * fFluxHist->Integral(minBin, minBin, intOpt.c_str()); } double lowBinUpEdge = fFluxHist->GetXaxis()->GetBinUpEdge(minBin); double highBinLowEdge = fFluxHist->GetXaxis()->GetBinLowEdge(maxBin); double lowBinfracIntegral = ((lowBinUpEdge - low) / fFluxHist->GetXaxis()->GetBinWidth(minBin)) * fFluxHist->Integral(minBin, minBin, intOpt.c_str()); double highBinfracIntegral = ((high - highBinLowEdge) / fFluxHist->GetXaxis()->GetBinWidth(maxBin)) * fFluxHist->Integral(maxBin, maxBin, intOpt.c_str()); // If they are neighbouring bins if ((minBin + 1) == maxBin) { // Get the contained fraction of the two bin's width return lowBinfracIntegral + highBinfracIntegral; } // If there are filled bins between them return lowBinfracIntegral + highBinfracIntegral + fFluxHist->Integral(minBin + 1, maxBin - 1, intOpt.c_str()); } //******************************************************************** double InputHandler::PredictedEventRate(double low, double high, std::string intOpt) { //******************************************************************** int minBin = fFluxHist->GetXaxis()->FindBin(low); int maxBin = fFluxHist->GetXaxis()->FindBin(high); return fEventHist->Integral(minBin, maxBin + 1, intOpt.c_str()); } diff --git a/src/GGM/CMakeLists.txt b/src/GGM/CMakeLists.txt index 3002059..bb99f25 100644 --- a/src/GGM/CMakeLists.txt +++ b/src/GGM/CMakeLists.txt @@ -1,51 +1,52 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES GGM_CC1ppip_Evt_1DQ2_nu.cxx GGM_CC1ppip_XSec_1DEnu_nu.cxx ) set(HEADERFILES GGM_CC1ppip_Evt_1DQ2_nu.h GGM_CC1ppip_XSec_1DEnu_nu.h ) set(LIBNAME expGGM) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/K2K/CMakeLists.txt b/src/K2K/CMakeLists.txt index de51e12..1a3f4f1 100644 --- a/src/K2K/CMakeLists.txt +++ b/src/K2K/CMakeLists.txt @@ -1,49 +1,50 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES K2K_NC1pi0_Evt_1Dppi0_nu.cxx ) set(HEADERFILES K2K_NC1pi0_Evt_1Dppi0_nu.h ) set(LIBNAME expK2K) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MCStudies/CMakeLists.txt b/src/MCStudies/CMakeLists.txt index 51e58d3..34f8924 100644 --- a/src/MCStudies/CMakeLists.txt +++ b/src/MCStudies/CMakeLists.txt @@ -1,60 +1,61 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx GenericFlux_Tester.cxx MCStudy_KaonPreSelection.cxx MCStudy_MuonValidation.cxx ) set(HEADERFILES ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h GenericFlux_Tester.h MCStudy_KaonPreSelection.h MCStudy_MuonValidation.h ) set(LIBNAME MCStudies) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) # Needed for experiment specific signal flags include_directories(${CMAKE_SOURCE_DIR}/src/T2K) include_directories(${CMAKE_SOURCE_DIR}/src/MINERvA) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MINERvA/CMakeLists.txt b/src/MINERvA/CMakeLists.txt index d3362bf..c1dc99f 100644 --- a/src/MINERvA/CMakeLists.txt +++ b/src/MINERvA/CMakeLists.txt @@ -1,119 +1,120 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES MINERvA_CCQE_XSec_1DQ2_antinu.cxx MINERvA_CCQE_XSec_1DQ2_joint.cxx MINERvA_CCQE_XSec_1DQ2_nu.cxx MINERvA_CC0pi_XSec_1DEe_nue.cxx MINERvA_CC0pi_XSec_1DQ2_nue.cxx MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx MINERvA_CC0pi_XSec_1DThetae_nue.cxx MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx MINERvA_CC1pi0_XSec_1Dth_antinu.cxx MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx MINERvA_CC1pip_XSec_1DTpi_nu.cxx MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx MINERvA_CC1pip_XSec_1Dth_nu.cxx MINERvA_CCNpip_XSec_1DEnu_nu.cxx MINERvA_CCNpip_XSec_1DQ2_nu.cxx MINERvA_CCNpip_XSec_1DTpi_nu.cxx MINERvA_CCNpip_XSec_1Dpmu_nu.cxx MINERvA_CCNpip_XSec_1Dth_nu.cxx MINERvA_CCNpip_XSec_1Dthmu_nu.cxx MINERvA_CCinc_XSec_2DEavq3_nu.cxx MINERvA_CCinc_XSec_1Dx_ratio.cxx MINERvA_CCinc_XSec_1DEnu_ratio.cxx MINERvA_CCinc_XSec_1Dx_nu.cxx MINERvA_CCinc_XSec_1DEnu_nu.cxx MINERvA_SignalDef.cxx ) set(HEADERFILES MINERvA_CCQE_XSec_1DQ2_antinu.h MINERvA_CCQE_XSec_1DQ2_joint.h MINERvA_CCQE_XSec_1DQ2_nu.h MINERvA_CC0pi_XSec_1DEe_nue.h MINERvA_CC0pi_XSec_1DQ2_nue.h MINERvA_CC0pi_XSec_1DQ2_nu_proton.h MINERvA_CC0pi_XSec_1DThetae_nue.h MINERvA_CC1pi0_XSec_1DEnu_antinu.h MINERvA_CC1pi0_XSec_1DQ2_antinu.h MINERvA_CC1pi0_XSec_1Dpmu_antinu.h MINERvA_CC1pi0_XSec_1Dppi0_antinu.h MINERvA_CC1pi0_XSec_1DTpi0_antinu.h MINERvA_CC1pi0_XSec_1Dth_antinu.h MINERvA_CC1pi0_XSec_1Dthmu_antinu.h MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h MINERvA_CC1pip_XSec_1DTpi_nu.h MINERvA_CC1pip_XSec_1Dth_20deg_nu.h MINERvA_CC1pip_XSec_1Dth_nu.h MINERvA_CCNpip_XSec_1DEnu_nu.h MINERvA_CCNpip_XSec_1DQ2_nu.h MINERvA_CCNpip_XSec_1DTpi_nu.h MINERvA_CCNpip_XSec_1Dpmu_nu.h MINERvA_CCNpip_XSec_1Dth_nu.h MINERvA_CCNpip_XSec_1Dthmu_nu.h MINERvA_CCinc_XSec_2DEavq3_nu.h MINERvA_CCinc_XSec_1Dx_ratio.h MINERvA_CCinc_XSec_1DEnu_ratio.h MINERvA_CCinc_XSec_1Dx_nu.h MINERvA_CCinc_XSec_1DEnu_nu.h MINERvA_SignalDef.h ) set(LIBNAME expMINERvA) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MiniBooNE/CMakeLists.txt b/src/MiniBooNE/CMakeLists.txt index 3706cd1..894dc61 100644 --- a/src/MiniBooNE/CMakeLists.txt +++ b/src/MiniBooNE/CMakeLists.txt @@ -1,89 +1,90 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx MiniBooNE_CCQE_XSec_1DQ2_nu.cxx MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx MiniBooNE_CCQE_XSec_2DTcos_nu.cxx MiniBooNE_CC1pip_XSec_1DTu_nu.cxx # MiniBooNE_NCEL_XSec_Treco_nu.cxx MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx ) set(HEADERFILES MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h MiniBooNE_CC1pi0_XSec_1DEnu_nu.h MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h MiniBooNE_CC1pi0_XSec_1DQ2_nu.h MiniBooNE_CCQE_XSec_1DQ2_antinu.h MiniBooNE_CC1pi0_XSec_1DTu_nu.h MiniBooNE_CC1pip_XSec_1DEnu_nu.h MiniBooNE_CCQE_XSec_1DQ2_nu.h MiniBooNE_CC1pip_XSec_1DQ2_nu.h MiniBooNE_CCQE_XSec_2DTcos_antinu.h MiniBooNE_CC1pip_XSec_1DTpi_nu.h MiniBooNE_CCQE_XSec_2DTcos_nu.h MiniBooNE_CC1pip_XSec_1DTu_nu.h # MiniBooNE_NCEL_XSec_Treco_nu.h MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h MiniBooNE_NCpi0_XSec_1Dppi0_nu.h ) set(LIBNAME expMiniBooNE) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Routines/CMakeLists.txt b/src/Routines/CMakeLists.txt index 1992163..b10b54b 100644 --- a/src/Routines/CMakeLists.txt +++ b/src/Routines/CMakeLists.txt @@ -1,64 +1,65 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES ComparisonRoutines.cxx SystematicRoutines.cxx SplineRoutines.cxx ) if(USE_MINIMIZER) set(IMPLFILES ${IMPLFILES};MinimizerRoutines.cxx) endif() set(HEADERFILES ComparisonRoutines.h SystematicRoutines.h SplineRoutines.h ) if(USE_MINIMIZER) set(HEADERFILES ${HEADERFILES};MinimizerRoutines.h) endif() set(LIBNAME Routines) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${EXP_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/FCN) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Splines/CMakeLists.txt b/src/Splines/CMakeLists.txt index ce76bba..10758aa 100644 --- a/src/Splines/CMakeLists.txt +++ b/src/Splines/CMakeLists.txt @@ -1,50 +1,51 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES FitSpline.cxx FitSplineHead.cxx ) set(HEADERFILES FitSpline.h FitSplineHead.h ) set(LIBNAME Splines) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/T2K/CMakeLists.txt b/src/T2K/CMakeLists.txt index 9fed3df..60aaec0 100644 --- a/src/T2K/CMakeLists.txt +++ b/src/T2K/CMakeLists.txt @@ -1,83 +1,84 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES T2K_CC0pi_XSec_2DPcos_nu.cxx T2K_CC1pip_CH_XSec_1DQ2_nu.cxx T2K_CC1pip_CH_XSec_1DWrec_nu.cxx T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx T2K_CC1pip_CH_XSec_1Dppi_nu.cxx T2K_CC1pip_CH_XSec_1Dq3_nu.cxx T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.cxx T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx T2K_CC1pip_H2O_XSec_1Dcosmu_nu.cxx T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.cxx T2K_CC1pip_H2O_XSec_1Dcospi_nu.cxx T2K_CC1pip_H2O_XSec_1Dpmu_nu.cxx T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx T2K_SignalDef.cxx ) set(HEADERFILES T2K_CC0pi_XSec_2DPcos_nu.h T2K_CC1pip_CH_XSec_1DQ2_nu.h T2K_CC1pip_CH_XSec_1DWrec_nu.h T2K_CC1pip_CH_XSec_1Dpmu_nu.h T2K_CC1pip_CH_XSec_1Dppi_nu.h T2K_CC1pip_CH_XSec_1Dq3_nu.h T2K_CC1pip_CH_XSec_1Dthmupi_nu.h T2K_CC1pip_CH_XSec_1Dthpi_nu.h T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h T2K_CC1pip_H2O_XSec_1Dcospi_nu.h T2K_CC1pip_H2O_XSec_1Dpmu_nu.h T2K_CC1pip_H2O_XSec_1Dppi_nu.h T2K_CC0pinp_STV_XSec_1Ddpt_nu.h T2K_SignalDef.h ) set(LIBNAME expT2K) 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(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Utils/CMakeLists.txt b/src/Utils/CMakeLists.txt index bd3a937..fee485f 100644 --- a/src/Utils/CMakeLists.txt +++ b/src/Utils/CMakeLists.txt @@ -1,63 +1,76 @@ # 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 <http://www.gnu.org/licenses/>. ################################################################################ set(HEADERFILES FitLogger.h FitParameters.h FitUtils.h GeneralUtils.h PlotUtils.h StatUtils.h SignalDef.h ) set(IMPLFILES PythiaQuiet.f FitLogger.cxx FitParameters.cxx FitUtils.cxx GeneralUtils.cxx PlotUtils.cxx StatUtils.cxx SignalDef.cxx ) set(LIBNAME Utils) 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(${RWENGINE_INCLUDE_DIRECTORIES}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) +target_include_directories(${LIBNAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(${LIBNAME} PUBLIC ${CMAKE_SOURCE_DIR}/src/FitBase) +target_include_directories(${LIBNAME} PUBLIC ${RWENGINE_INCLUDE_DIRECTORIES}) + +# if(USE_NuWro AND NUWRO_BUILT_FROM_FILE) +# target_include_directories(${LIBNAME} PUBLIC ${CMAKE_BINARY_DIR}/NuWro_event1) +# endif() + 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}) +add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) +add_executable(DumpROOTClassesFromVector DumpROOTClassesFromVector.cxx GeneralUtils.cxx FitLogger.cxx PythiaQuiet.f) +target_link_libraries(DumpROOTClassesFromVector ${ROOT_LIBS}) +if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "") + set_target_properties(DumpROOTClassesFromVector PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS}) +endif() +set_target_properties(DumpROOTClassesFromVector PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) +install(TARGETS DumpROOTClassesFromVector DESTINATION bin) diff --git a/src/Utils/DumpROOTClassesFromVector.cxx b/src/Utils/DumpROOTClassesFromVector.cxx new file mode 100644 index 0000000..7c22652 --- /dev/null +++ b/src/Utils/DumpROOTClassesFromVector.cxx @@ -0,0 +1,128 @@ +// 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 <http://www.gnu.org/licenses/>. +*******************************************************************************/ + +#include "GeneralUtils.h" + +#include "TCollection.h" +#include "TError.h" +#include "TFile.h" +#include "TStreamerInfo.h" +#include "TString.h" +#include "TTree.h" + +#include <algorithm> +#include <fstream> +#include <iostream> + +int main(int argc, char const* argv[]) { + // shhh ROOT it okay. + gErrorIgnoreLevel = kError; + + if (argc != 4) { + std::cout << "[ERROR](DumpROOTClassesFromVector): Recieved " << (argc - 1) + << " CLI opts." << std::endl; + for (int i = 1; i < argc; ++i) { + std::cout << "[" << i << "] \"" << argv[i] << "\"" << std::endl; + } + std::cout << "Usage: " << argv[0] + << " <Input ROOT filename> " + "<Project source output directory> <ClassName Prefix To " + "Include in LinkDef>" + << std::endl; + return 1; + } + char const* ROOTFileName = argv[1]; + char const* OutputDirectoryName = argv[2]; + char const* CSLClasses = argv[3]; + TFile* fl = TFile::Open(ROOTFileName); + if (!fl || !fl->IsOpen()) { + std::cerr + << "[ERROR](DumpROOTClassesFromVector): Failed to open root file: " + << fl << std::endl; + return 1; + } + std::cout << "[INFO]: Writing project files to " << OutputDirectoryName + << std::endl; + fl->MakeProject(OutputDirectoryName); + + TIter next(fl->GetStreamerInfoList()); + TStreamerInfo* inf = 0; + std::vector<std::string> ClassesToFind = + GeneralUtils::ParseToStr(CSLClasses, ","); + + if (!ClassesToFind.size() || !ClassesToFind[0].length()) { + std::cerr + << "[ERROR](DumpROOTClassesFromVector): No classes to find passed in." + << std::endl; + return 2; + } + + std::vector<std::string> ClassesToLink; + while ((inf = dynamic_cast<TStreamerInfo*>(next()))) { + std::cout << "[INFO]: Have StreamerInfo for class: " << inf->GetName() + << std::endl; + for (size_t ClTF_it = 0; ClTF_it < ClassesToFind.size(); ++ClTF_it) { + if (std::string(inf->GetName()) == ClassesToFind[ClTF_it]) { + ClassesToLink.push_back(inf->GetName()); + std::cout << "[INFO]: Including streamer info for: " << inf->GetName() + << " in generated LinkDef" << std::endl; + } + } + } + + if (ClassesToFind.size() > ClassesToLink.size()) { + std::cerr << "[ERROR](DumpROOTClassesFromVector): Only found " + << ClassesToLink.size() + << " classes to include in the ROOT library, expected at least " + << ClassesToFind.size() << std::endl; + return 1; + } + + std::string OutputDir(OutputDirectoryName); + + size_t pos = OutputDir.find_last_of('/'); + pos = (pos == std::string::npos) ? 0 : pos; + + std::string LinkDef_loc = + OutputDir + "/" + OutputDir.substr(pos) + "LinkDef.h"; + std::cout << "[INFO]: Writing LinkDef to: " << LinkDef_loc << std::endl; + std::ofstream LinkDefos(LinkDef_loc.c_str()); + + if (!LinkDefos.is_open()) { + std::cerr << "[ERROR] Couldn't open " << LinkDef_loc << " for writing." + << std::endl; + } + + LinkDefos << "#ifdef __CINT__" << std::endl; + for (size_t ClTL_it = 0; ClTL_it < ClassesToLink.size(); ++ClTL_it) { + LinkDefos << "#pragma link C++ class " << ClassesToLink[ClTL_it] << "+;" + << std::endl; + } + LinkDefos << "#endif" << std::endl; + LinkDefos.close(); + + std::string Instances_loc = + OutputDir + "/" + OutputDir.substr(pos) + "ProjectInstances.h"; + std::ofstream Instancesos(Instances_loc.c_str()); + if (!Instancesos.is_open()) { + std::cerr << "[ERROR] Couldn't open " << Instances_loc << " for writing." + << std::endl; + } + Instancesos.close(); +}