diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47a64c9..d2537af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,74 +1,80 @@
# Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
#Use the compilers found in the path
find_program(CMAKE_C_COMPILER NAMES $ENV{CC} gcc PATHS ENV PATH NO_DEFAULT_PATH)
find_program(CMAKE_CXX_COMPILER NAMES $ENV{CXX} g++ PATHS ENV PATH NO_DEFAULT_PATH)
project(NUISANCE)
include(ExternalProject)
set (NUISANCE_VERSION_MAJOR 3)
set (NUISANCE_VERSION_MINOR 0)
set (NUISANCE_VERSION_REVISION 0)
set (NUISANCE_VERSION_STRING "v${NUISANCE_VERSION_MAJOR}r${NUISANCE_VERSION_MINOR}")
if(${NUISANCE_VERSION_REVISION} STRGREATER "0")
set (NUISANCE_VERSION_STRING "${NUISANCE_VERSION_STRING}p${NUISANCE_VERSION_REVISION}")
endif()
#Set this to TRUE to enable build debugging messages
set(BUILD_DEBUG_MSGS TRUE)
include(${CMAKE_SOURCE_DIR}/cmake/cmessage.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/cacheVariables.cmake)
cmessage(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"")
cmessage(STATUS "CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"")
################################################################################
# Check Dependencies
################################################################################
################################## ROOT ######################################
include(${CMAKE_SOURCE_DIR}/cmake/ROOTSetup.cmake)
################################# InputHandler #################################
include(${CMAKE_SOURCE_DIR}/cmake/InputHandlerSetup.cmake)
################################# Pythia6/8 ###################################
include(${CMAKE_SOURCE_DIR}/cmake/pythia6Setup.cmake)
################################## FHICLCPP ####################################
include(${CMAKE_SOURCE_DIR}/cmake/fhiclcppSetup.cmake)
#Need this to be at the front
LIST(REVERSE EXTRA_CXX_FLAGS)
LIST(APPEND EXTRA_CXX_FLAGS -I${CMAKE_SOURCE_DIR}/src)
LIST(REVERSE EXTRA_CXX_FLAGS)
################################## COMPILER ####################################
include(${CMAKE_SOURCE_DIR}/cmake/c++CompilerSetup.cmake)
################################################################################
add_subdirectory(src)
+
+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})
diff --git a/cmake/setup.sh.in b/cmake/setup.sh.in
new file mode 100644
index 0000000..44d8d3f
--- /dev/null
+++ b/cmake/setup.sh.in
@@ -0,0 +1,159 @@
+# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
+
+################################################################################
+# This file is part of NUISANCE.
+#
+# NUISANCE is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# NUISANCE is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with NUISANCE. If not, see .
+################################################################################
+
+#!/bin/sh
+
+### Adapted from https://unix.stackexchange.com/questions/4965/keep-duplicates-out-of-path-on-source
+function add_to_PATH () {
+ for d; do
+
+ d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links
+ if [ -z "$d" ]; then continue; fi # skip nonexistent directory
+
+ if [ "$d" == "/usr/bin" ] || [ "$d" == "/usr/bin64" ] || [ "$d" == "/usr/local/bin" ] || [ "$d" == "/usr/local/bin64" ]; then
+ case ":$PATH:" in
+ *":$d:"*) :;;
+ *) export PATH=$PATH:$d;;
+ esac
+ else
+ case ":$PATH:" in
+ *":$d:"*) :;;
+ *) export PATH=$d:$PATH;;
+ esac
+ fi
+ done
+}
+
+function add_to_LD_LIBRARY_PATH () {
+ for d; do
+
+ d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links
+ if [ -z "$d" ]; then continue; fi # skip nonexistent directory
+
+ if [ "$d" == "/usr/lib" ] || [ "$d" == "/usr/lib64" ] || [ "$d" == "/usr/local/lib" ] || [ "$d" == "/usr/local/lib64" ]; then
+ case ":$LD_LIBRARY_PATH:" in
+ *":$d:"*) :;;
+ *) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$d;;
+ esac
+ else
+ case ":$LD_LIBRARY_PATH:" in
+ *":$d:"*) :;;
+ *) export LD_LIBRARY_PATH=$d:$LD_LIBRARY_PATH;;
+ esac
+ fi
+ done
+}
+
+if [ "@EXTRA_SETUP_SCRIPT@" ]; then
+ if [ ! -e @EXTRA_SETUP_SCRIPT@ ]; then
+ echo "[WARN]: Extra setup script \"@EXTRA_SETUP_SCRIPT@\" requested, but could not be found. Skipping..."
+ else
+ echo "[INFO]: Sourcing extra setup from \"@EXTRA_SETUP_SCRIPT@\"."
+ . @EXTRA_SETUP_SCRIPT@
+ fi
+fi
+
+add_to_PATH "@CMAKE_INSTALL_PREFIX@/bin"
+
+add_to_LD_LIBRARY_PATH "@CMAKE_INSTALL_PREFIX@/lib"
+
+if [ ! "${ROOTSYS}" ]; then
+ echo "[INFO]: Sourcing ROOT from: @CMAKE_ROOTSYS@"
+ source "@CMAKE_ROOTSYS@/bin/thisroot.sh"
+fi
+
+if [ "@USE_T2K@" != "FALSE" ]; then
+ echo "[INFO]: Adding T2K paths to the environment."
+ export T2KREWEIGHT=@T2KREWEIGHT@
+ add_to_LD_LIBRARY_PATH "@T2KREWEIGHT@/lib"
+fi
+
+if [ "@USE_NIWG@" != "FALSE" ]; then
+ echo "[INFO]: Adding NIWG paths to the environment."
+ export NIWG=@NIWG_ROOT@
+ export NIWGREWEIGHT_INPUTS=@NIWG_ROOT@/inputs
+ add_to_LD_LIBRARY_PATH "@NIWG_ROOT@"
+fi
+
+if [ "@USE_NEUT@" != "FALSE" ]; then
+ echo "[INFO]: Adding NEUT library paths to the environment."
+ export NEUT_ROOT=@NEUT_ROOT@
+ export CERN=@CERN@
+ export CERN_LEVEL=@CERN_LEVEL@
+ add_to_LD_LIBRARY_PATH "${NEUT_LIB_DIR}" "${NEUT_ROOT}/src/reweight"
+fi
+
+if [ "@USE_NuWro@" != "FALSE" ]; then
+ if [ "@NUWRO_BUILT_FROM_FILE@" == "FALSE" ]; then
+ echo "[INFO]: Adding NuWro library paths to the environment."
+ export NUWRO="@NUWRO@"
+
+ add_to_PATH "@NUWRO@/bin"
+ add_to_LD_LIBRARY_PATH "@NUWRO@/build/@CMAKE_SYSTEM_NAME@/lib"
+
+ if [ "@NUWRO_INC@" ]; then
+ export NUWRO_INC=@NUWRO_INC@
+ fi
+
+ else
+ echo "[INFO]: NuWro support included from input event file."
+ fi
+fi
+
+if [ "@NEED_PYTHIA6@" != "FALSE" ]; then
+ echo "[INFO]: Adding PYTHIA6 library paths to the environment."
+ export PYTHIA6="@PYTHIA6@"
+
+ add_to_LD_LIBRARY_PATH "@PYTHIA6@"
+fi
+
+if [ "@USE_GENIE@" != "FALSE" ]; then
+ echo "[INFO]: Adding GENIE paths to the environment."
+
+ export GENIE="@GENIE@"
+
+ export LHAPDF_LIB="@LHAPDF_LIB@"
+ export LHAPDF_INC="@LHAPDF_INC@"
+
+ export LIBXML2_LIB="@LIBXML2_LIB@"
+ export LIBXML2_INC="@LIBXML2_INC@"
+
+ export LOG4CPP_LIB="@LOG4CPP_LIB@"
+ export LOG4CPP_INC="@LOG4CPP_INC@"
+
+ if [ "@LHAPATH@" ]; then
+ export LHAPATH="@LHAPATH@"
+ fi
+
+ add_to_PATH "@GENIE@/bin"
+
+ add_to_LD_LIBRARY_PATH "@GENIE@/lib" "@LHAPDF_LIB@" "@LIBXML2_LIB@" "@LOG4CPP_LIB@"
+
+fi
+
+if [ "@BUILD_GiBUU@" != "FALSE" ]; then
+ echo "[INFO]: Sourcing GiBUU tools."
+ source @CMAKE_BINARY_DIR@/GiBUUTools/src/GiBUUTools-build/Linux/setup.sh
+fi
+
+if [ "@NUSYST_ROOT@" != "" ]; then
+ source @NUSYST_ROOT@/setup.sh
+fi
+
+export NUISANCE="@CMAKE_SOURCE_DIR@"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 26db198..6a69ff2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,9 @@
add_subdirectory(config)
add_subdirectory(core)
add_subdirectory(plugins)
add_subdirectory(utility)
add_subdirectory(generator)
+add_subdirectory(samples)
+
add_subdirectory(app)
diff --git a/src/app/DumpEventInfo.cxx b/src/app/DumpEventInfo.cxx
index 3455253..b65b10c 100644
--- a/src/app/DumpEventInfo.cxx
+++ b/src/app/DumpEventInfo.cxx
@@ -1,27 +1,34 @@
#include "config/GlobalConfiguration.hxx"
#include "core/IInputHandler.hxx"
#include "core/MinimalEvent.hxx"
+#include "samples/ISample.hxx"
+
#include "plugins/Instantiate.hxx"
#include "fhiclcpp/make_ParameterSet.h"
#include
int main() {
nuis::config::EnsureConfigurationRead("./nuis.global.config.fcl");
fhicl::ParameterSet ps = fhicl::make_ParameterSet("./test.fcl");
- nuis::plugins::plugin_traits::unique_ptr_t IH =
- nuis::plugins::Instantiate(
- ps.get("sample.InputHandler"));
+ for (fhicl::ParameterSet const &samp_config :
+ ps.get>("samples")) {
+
+ std::cout << "[INFO]: Reading sample: "
+ << samp_config.get("name") << std::endl;
- IH->Initialize(ps.get("sample"));
+ nuis::plugins::plugin_traits::unique_ptr_t sample =
+ nuis::plugins::Instantiate(
+ samp_config.get("name"));
+
- for(IInputHandler::ev_index_t ev_it = 0; ev_it < IH->GetNEvents(); ++ev_it){
- nuis::core::MinimalEvent const &ev = IH->GetMinimalEvent(ev_it);
+ sample->Initialize(samp_config);
+ sample->ProcessSample();
}
}
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index ad886b2..1aa7703 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -1,19 +1,19 @@
set(core_implementation_files
FullEvent.cxx
-# InputManager.cxx
+InputManager.cxx
MinimalEvent.cxx
Particle.cxx)
set(core_header_files
FullEvent.hxx
-# InputManager.hxx
+InputManager.hxx
MinimalEvent.hxx
Particle.hxx
IInputHandler.hxx
types.hxx)
add_library(nuis_core SHARED ${core_implementation_files})
target_link_libraries(nuis_core)
install(TARGETS nuis_core DESTINATION lib)
install(FILES ${core_header_files} DESTINATION include/core)
diff --git a/src/core/IInputHandler.hxx b/src/core/IInputHandler.hxx
index f6ee96a..94aaebf 100644
--- a/src/core/IInputHandler.hxx
+++ b/src/core/IInputHandler.hxx
@@ -1,57 +1,109 @@
// Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#ifndef CORE_IINPUTHANDLER_HXX_SEEN
#define CORE_IINPUTHANDLER_HXX_SEEN
#include "plugins/traits.hxx"
#include "exception/exception.hxx"
+#include
+
namespace fhicl {
class ParameterSet;
}
namespace nuis {
namespace core {
class MinimalEvent;
class FullEvent;
} // namespace core
} // namespace nuis
class IInputHandler {
public:
+ struct FullEvent_const_iterator
+ : public std::iterator<
+ std::input_iterator_tag, nuis::core::FullEvent const, size_t,
+ nuis::core::FullEvent const *, nuis::core::FullEvent const &> {
+
+ FullEvent_const_iterator(size_t _idx, IInputHandler const *_ih) {
+ idx = _idx;
+ ih = _ih;
+ }
+ FullEvent_const_iterator(FullEvent_const_iterator const &other) {
+ idx = other.idx;
+ ih = other.ih;
+ }
+ FullEvent_const_iterator operator=(FullEvent_const_iterator const &other) {
+ idx = other.idx;
+ ih = other.ih;
+ return (*this);
+ }
+
+ bool operator==(FullEvent_const_iterator const &other) {
+ return (idx == other.idx);
+ }
+ bool operator!=(FullEvent_const_iterator const &other) {
+ return !(*this == other);
+ }
+ nuis::core::FullEvent const &operator*() { return ih->GetFullEvent(idx); }
+ nuis::core::FullEvent const *operator->() { return &ih->GetFullEvent(idx); }
+
+ FullEvent_const_iterator operator++() {
+ idx++;
+ return *this;
+ }
+ FullEvent_const_iterator operator++(int) {
+ FullEvent_const_iterator tmp(*this);
+ idx++;
+ return tmp;
+ }
+
+ private:
+ size_t idx;
+ IInputHandler const *ih;
+ };
NEW_NUIS_EXCEPT(invalid_input_file);
NEW_NUIS_EXCEPT(invalid_entry);
typedef size_t ev_index_t;
virtual void Initialize(fhicl::ParameterSet const &) = 0;
- virtual nuis::core::MinimalEvent const &GetMinimalEvent(ev_index_t idx) = 0;
- virtual nuis::core::FullEvent const &GetFullEvent(ev_index_t idx) = 0;
+ virtual nuis::core::MinimalEvent const &
+ GetMinimalEvent(ev_index_t idx) const = 0;
+ virtual nuis::core::FullEvent const &GetFullEvent(ev_index_t idx) const = 0;
+
+ virtual size_t GetNEvents() const = 0;
- virtual size_t GetNEvents() = 0;
+ FullEvent_const_iterator begin() const {
+ return FullEvent_const_iterator(0, this);
+ }
+ FullEvent_const_iterator end() const {
+ return FullEvent_const_iterator(GetNEvents(), this);
+ }
- virtual ~IInputHandler(){}
+ virtual ~IInputHandler() {}
};
DECLARE_PLUGIN_INTERFACE(IInputHandler);
#endif
diff --git a/src/core/InputManager.cxx b/src/core/InputManager.cxx
index 938211f..12cfce8 100644
--- a/src/core/InputManager.cxx
+++ b/src/core/InputManager.cxx
@@ -1,22 +1,65 @@
#include "core/InputManager.hxx"
+#include "plugins/Instantiate.hxx"
+
+#include "fhiclcpp/ParameterSet.h"
+
+#include
+
namespace nuis {
namespace core {
+InputManager *InputManager::_global_inst = nullptr;
+
+InputManager::NamedInputHandler::NamedInputHandler(
+ std::string const &file,
+ plugins::plugin_traits::unique_ptr_t &&IH) {
+ name = file;
+ handler = std::move(IH);
+}
+
+InputManager::InputManager() : Inputs() {}
+
+InputManager &InputManager::Get() {
+ if (!_global_inst) {
+ _global_inst = new InputManager();
+ }
+ return *_global_inst;
+}
+
InputManager::Input_id_t
-InputManager::EnsureInputLoaded(std::string const &file_name) {
+InputManager::EnsureInputLoaded(fhicl::ParameterSet const &ps) {
+ std::string const &file_name = ps.get("file");
for (size_t i = 0; i < Inputs.size(); ++i) {
if (Inputs[i].name == file_name) {
return i;
}
}
- Inputs.push_back(NamedInputHandler{
- file_name,
- });
+ Inputs.emplace_back(file_name,
+ nuis::plugins::Instantiate(
+ ps.get("input_type") + "InputHandler"));
+ Inputs.back().handler->Initialize(ps);
+ return (Inputs.size() - 1);
}
InputManager::Input_id_t
-InputManager::GetInputId(std::string const &file_name) {}
-IInputHandler &InputManager::GetInputHandler(InputManager::Input_id_t id) {}
+InputManager::GetInputId(std::string const &file_name) const {
+ for (size_t i = 0; i < Inputs.size(); ++i) {
+ if (Inputs[i].name == file_name) {
+ return i;
+ }
+ }
+ throw unknown_input() << "[ERROR]: Input file " << std::quoted(file_name)
+ << " has not been loaded.";
+}
+IInputHandler const &
+InputManager::GetInputHandler(InputManager::Input_id_t id) const {
+ if (id >= Inputs.size()) {
+ throw unknown_input() << "[ERROR]: Attempted to get input with id " << id
+ << ", but only have " << Inputs.size()
+ << " loaded inputs.";
+ }
+ return *Inputs[id].handler.get();
+}
} // namespace core
} // namespace nuis
diff --git a/src/core/InputManager.hxx b/src/core/InputManager.hxx
index f965335..c30c9cc 100644
--- a/src/core/InputManager.hxx
+++ b/src/core/InputManager.hxx
@@ -1,52 +1,64 @@
// Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#ifndef CORE_INPUTMANAGER_HXX_SEEN
#define CORE_INPUTMANAGER_HXX_SEEN
-#include
+#include "core/IInputHandler.hxx"
+
+#include "plugins/traits.hxx"
+
+#include "exception/exception.hxx"
+
#include
#include
-namespace nuis {
-namespace core {
-class IInputHandler;
+namespace fhicl {
+class ParameterSet;
}
-} // namespace nuis
namespace nuis {
namespace core {
class InputManager {
struct NamedInputHandler {
+ NamedInputHandler(std::string const &,
+ plugins::plugin_traits::unique_ptr_t &&);
std::string name;
- std::unique_ptr handler;
+ plugins::plugin_traits::unique_ptr_t handler;
};
std::vector Inputs;
+ InputManager();
+
+ static InputManager *_global_inst;
public:
+
+ static InputManager &Get();
+
+ NEW_NUIS_EXCEPT(unknown_input);
typedef size_t Input_id_t;
- Input_id_t EnsureInputLoaded(std::string const &file_name);
- Input_id_t GetInputId(std::string const &file_name);
- IInputHandler &GetInputHandler(Input_id_t id);
+ Input_id_t EnsureInputLoaded(fhicl::ParameterSet const &);
+ Input_id_t GetInputId(std::string const &) const;
+ IInputHandler const &GetInputHandler(Input_id_t) const;
};
} // namespace core
} // namespace nuis
#endif
diff --git a/src/generator/CMakeLists.txt b/src/generator/CMakeLists.txt
index 85c0136..45c16fe 100644
--- a/src/generator/CMakeLists.txt
+++ b/src/generator/CMakeLists.txt
@@ -1,7 +1,6 @@
-
if(USE_NuWro)
add_library(InputHandlers SHARED NuWroInputHandler.cxx)
target_link_libraries(InputHandlers nuis_core nuis_config)
install(TARGETS InputHandlers DESTINATION plugins)
endif(USE_NuWro)
diff --git a/src/generator/NuWroInputHandler.cxx b/src/generator/NuWroInputHandler.cxx
index 10b1380..9a951c6 100644
--- a/src/generator/NuWroInputHandler.cxx
+++ b/src/generator/NuWroInputHandler.cxx
@@ -1,42 +1,44 @@
#include "NuWroInputHandler.hxx"
#include "core/FullEvent.hxx"
#include "utility/ROOTUtility.hxx"
#include "fhiclcpp/ParameterSet.h"
using namespace nuis::core;
using namespace nuis::utility;
NuWroInputHandler::NuWroInputHandler() : fInputTree(nullptr) {}
NuWroInputHandler::NuWroInputHandler(NuWroInputHandler &&other)
: fInputTree(std::move(other.fInputTree)),
fReaderEvent(std::move(other.fReaderEvent)) {}
void NuWroInputHandler::Initialize(fhicl::ParameterSet const &ps) {
fInputTree = CheckGetTTree(ps.get("file"), "treeout");
fReaderEvent.fNuWroEvent = nullptr;
fInputTree->tree->SetBranchAddress("e", &fReaderEvent.fNuWroEvent);
}
-MinimalEvent const &NuWroInputHandler::GetMinimalEvent(ev_index_t idx) {
+MinimalEvent const &NuWroInputHandler::GetMinimalEvent(ev_index_t idx) const {
if (idx >= GetNEvents()) {
throw IInputHandler::invalid_entry()
<< "[ERROR]: Attempted to get entry " << idx
<< " from an InputHandler with only " << GetNEvents();
}
fInputTree->tree->GetEntry(idx);
return fReaderEvent;
}
-FullEvent const &NuWroInputHandler::GetFullEvent(ev_index_t idx) {
+FullEvent const &NuWroInputHandler::GetFullEvent(ev_index_t idx) const {
(void)GetMinimalEvent(idx);
- //Fill particle stack
+ // Fill particle stack
return fReaderEvent;
}
-size_t NuWroInputHandler::GetNEvents() { return fInputTree->tree->GetEntries(); }
+size_t NuWroInputHandler::GetNEvents() const {
+ return fInputTree->tree->GetEntries();
+}
-DECLARE_PLUGIN(IInputHandler,NuWroInputHandler);
+DECLARE_PLUGIN(IInputHandler, NuWroInputHandler);
diff --git a/src/generator/NuWroInputHandler.hxx b/src/generator/NuWroInputHandler.hxx
index 184cb96..750748a 100644
--- a/src/generator/NuWroInputHandler.hxx
+++ b/src/generator/NuWroInputHandler.hxx
@@ -1,56 +1,56 @@
// Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#ifndef GENERATOR_NUWROINPUTHANDLER_HXX_SEEN
#define GENERATOR_NUWROINPUTHANDLER_HXX_SEEN
#include "core/IInputHandler.hxx"
#include "core/FullEvent.hxx"
#include
namespace fhicl {
class ParameterSet;
}
namespace nuis {
namespace core {
class MinimalEvent;
} // namespace core
namespace utility {
class TreeFile;
}
} // namespace nuis
class NuWroInputHandler : public IInputHandler {
- std::unique_ptr fInputTree;
- nuis::core::FullEvent fReaderEvent;
+ mutable std::unique_ptr fInputTree;
+ mutable nuis::core::FullEvent fReaderEvent;
public:
NuWroInputHandler();
NuWroInputHandler(NuWroInputHandler const &) = delete;
NuWroInputHandler(NuWroInputHandler &&);
void Initialize(fhicl::ParameterSet const &);
- nuis::core::MinimalEvent const &GetMinimalEvent(ev_index_t idx);
- nuis::core::FullEvent const &GetFullEvent(ev_index_t idx);
- size_t GetNEvents();
+ nuis::core::MinimalEvent const &GetMinimalEvent(ev_index_t idx) const;
+ nuis::core::FullEvent const &GetFullEvent(ev_index_t idx) const;
+ size_t GetNEvents() const;
};
#endif
diff --git a/src/samples/CMakeLists.txt b/src/samples/CMakeLists.txt
new file mode 100644
index 0000000..98771ed
--- /dev/null
+++ b/src/samples/CMakeLists.txt
@@ -0,0 +1,6 @@
+set(samples_header_files
+ISample.hxx)
+
+install(FILES ${samples_header_files} DESTINATION include/samples)
+
+add_subdirectory(MCTools)
diff --git a/src/core/InputManager.hxx b/src/samples/IDataComparison.hxx
similarity index 59%
copy from src/core/InputManager.hxx
copy to src/samples/IDataComparison.hxx
index f965335..f73db5b 100644
--- a/src/core/InputManager.hxx
+++ b/src/samples/IDataComparison.hxx
@@ -1,52 +1,32 @@
// Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
-#ifndef CORE_INPUTMANAGER_HXX_SEEN
-#define CORE_INPUTMANAGER_HXX_SEEN
+#ifndef SAMPLES_IDATACOMPARISON_HXX_SEEN
+#define SAMPLES_IDATACOMPARISON_HXX_SEEN
-#include
-#include
-#include
+#include "samples/ISample.hxx"
-namespace nuis {
-namespace core {
-class IInputHandler;
-}
-} // namespace nuis
+class IDataComparison : public ISample {
-namespace nuis {
-namespace core {
-class InputManager {
- struct NamedInputHandler {
- std::string name;
- std::unique_ptr handler;
- };
- std::vector Inputs;
-
-public:
- typedef size_t Input_id_t;
-
- Input_id_t EnsureInputLoaded(std::string const &file_name);
- Input_id_t GetInputId(std::string const &file_name);
- IInputHandler &GetInputHandler(Input_id_t id);
+ double GetGOF() = 0;
};
-} // namespace core
-} // namespace nuis
+
+DECLARE_PLUGIN_INTERFACE(IDataComparison);
#endif
diff --git a/src/core/IInputHandler.hxx b/src/samples/ISample.hxx
similarity index 73%
copy from src/core/IInputHandler.hxx
copy to src/samples/ISample.hxx
index f6ee96a..2333cbd 100644
--- a/src/core/IInputHandler.hxx
+++ b/src/samples/ISample.hxx
@@ -1,57 +1,53 @@
// Copyright 2018 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
-#ifndef CORE_IINPUTHANDLER_HXX_SEEN
-#define CORE_IINPUTHANDLER_HXX_SEEN
+#ifndef SAMPLES_ISAMPLE_HXX_SEEN
+#define SAMPLES_ISAMPLE_HXX_SEEN
#include "plugins/traits.hxx"
#include "exception/exception.hxx"
namespace fhicl {
class ParameterSet;
}
namespace nuis {
namespace core {
-class MinimalEvent;
class FullEvent;
+class MinimalEvent;
} // namespace core
} // namespace nuis
-class IInputHandler {
+class ISample {
public:
-
- NEW_NUIS_EXCEPT(invalid_input_file);
- NEW_NUIS_EXCEPT(invalid_entry);
-
- typedef size_t ev_index_t;
+ NEW_NUIS_EXCEPT(uninitialized_ISample);
virtual void Initialize(fhicl::ParameterSet const &) = 0;
- virtual nuis::core::MinimalEvent const &GetMinimalEvent(ev_index_t idx) = 0;
- virtual nuis::core::FullEvent const &GetFullEvent(ev_index_t idx) = 0;
- virtual size_t GetNEvents() = 0;
+ virtual void ProcessSample() = 0;
+
+ virtual void Write() = 0;
- virtual ~IInputHandler(){}
+ virtual ~ISample(){}
};
-DECLARE_PLUGIN_INTERFACE(IInputHandler);
+DECLARE_PLUGIN_INTERFACE(ISample);
#endif
diff --git a/src/samples/MCTools/CMakeLists.txt b/src/samples/MCTools/CMakeLists.txt
new file mode 100644
index 0000000..0f760ae
--- /dev/null
+++ b/src/samples/MCTools/CMakeLists.txt
@@ -0,0 +1,8 @@
+if(USE_NuWro)
+ LIST(APPEND MC_TOOL_IMPL NuisToNuWro.cxx)
+endif(USE_NuWro)
+
+add_library(MCTools SHARED ${MC_TOOL_IMPL})
+target_link_libraries(MCTools nuis_core nuis_config)
+
+install(TARGETS MCTools DESTINATION plugins)
diff --git a/src/samples/MCTools/NuisToNuWro.cxx b/src/samples/MCTools/NuisToNuWro.cxx
new file mode 100644
index 0000000..68ae343
--- /dev/null
+++ b/src/samples/MCTools/NuisToNuWro.cxx
@@ -0,0 +1,40 @@
+#include "samples/ISample.hxx"
+
+#include "core/InputManager.hxx"
+#include "core/FullEvent.hxx"
+
+#include
+#include
+
+using namespace nuis::core;
+
+class NuisToNuWro : public ISample {
+public:
+ InputManager::Input_id_t fIH_id;
+
+ NuisToNuWro()
+ : fIH_id(std::numeric_limits::max()) {}
+
+ void Initialize(fhicl::ParameterSet const &ps) {
+ fIH_id = InputManager::Get().EnsureInputLoaded(ps);
+ }
+
+ void Process(FullEvent const &ps) {
+ std::cout << ps.fNuWroEvent->dyn << std::endl;
+ }
+
+ void ProcessSample() {
+ if (fIH_id == std::numeric_limits::max()) {
+ throw uninitialized_ISample();
+ }
+
+ IInputHandler const &IH = InputManager::Get().GetInputHandler(fIH_id);
+ for (auto const &fe : IH) {
+ Process(fe);
+ }
+ }
+
+ void Write() {}
+};
+
+DECLARE_PLUGIN(ISample, NuisToNuWro);