Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
pull_request:
workflow_dispatch:

jobs:
build:
name: Build (prof)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Apptainer
run: |
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update -qq
sudo apt-get install -y apptainer

- name: Setup CVMFS
uses: cvmfs-contrib/github-action-cvmfs@v4
with:
cvmfs_repositories: "dune.opensciencegrid.org,larsoft.opensciencegrid.org,fermilab.opensciencegrid.org,oasis.opensciencegrid.org,singularity.opensciencegrid.org"

# NOTE: bash -c (no -e) is required. UPS products/setup uses &&/|| chains
# that return non-zero when running under sh (e.g. "test $ss = csh && ...").
# bash -e would treat those as fatal errors. Interactive singularity shells
# work because set -e is off by default. cmake exits are checked explicitly.
- name: Build
run: |
apptainer exec \
--bind /cvmfs \
--bind "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" \
/cvmfs/singularity.opensciencegrid.org/fermilab/fnal-wn-sl7:latest \
bash -c "
cd '${GITHUB_WORKSPACE}'
source ndcaf_setup.sh prof
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release || exit \$?
cmake --build build -j\$(nproc) || exit \$?
" 2>&1
196 changes: 196 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
cmake_minimum_required(VERSION 3.20)
project(ND_CAFMaker LANGUAGES CXX)
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 5.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(ENABLE_TMS "Enable TMS reconstruction branch filler" ON)
option(ENABLE_TESTEXE "Build the testHDF test executable" OFF)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

string(
APPEND
CMAKE_CXX_FLAGS
" -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion"
" -Wshadow -Wimplicit-fallthrough -Wextra-semi -Wold-style-cast"
" -fno-omit-frame-pointer")

string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fsanitize=address,undefined")

string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " -fsanitize=address,undefined")

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -D_GLIBCXX_SANITIZE_STD_ALLOCATOR")
endif()

add_compile_definitions(NO_ART)

include(cmake/FindUPSPackage.cmake)

# ROOT — always via ROOTConfig.cmake (ships with ROOT >= 6)
find_package(ROOT 6 REQUIRED COMPONENTS Core MathMore Geom EGPythia6 GenVector)
add_library(deps::root_glibs INTERFACE IMPORTED)
set_target_properties(
deps::root_glibs
PROPERTIES
INTERFACE_LINK_LIBRARIES
"ROOT::Core;ROOT::MathMore;ROOT::Geom;ROOT::EGPythia6;ROOT::GenVector")

# Versions are pinned by ndcaf_setup.sh; env vars are set by UPS at runtime.

find_program(GENIE_CONFIG genie-config HINTS "$ENV{GENIE_FQ_DIR}/bin"
REQUIRED)

execute_process(
COMMAND ${GENIE_CONFIG} --libs
OUTPUT_VARIABLE _genie_libs
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_library(deps::genie INTERFACE IMPORTED)
set_target_properties(
deps::genie PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$ENV{GENIE_FQ_DIR}/include/GENIE"
INTERFACE_LINK_LIBRARIES "${_genie_libs}")

if("$ENV{HDF5_FQ_DIR}" MATCHES "debug")
set(_hdf5_lib hdf5_cpp_debug)
else()
set(_hdf5_lib hdf5_cpp)
endif()

find_ups_package(
TARGET_NAME deps::hdf5
INC_VAR HDF5_INC
LIB_VAR HDF5_LIB
LIBS ${_hdf5_lib}
REQUIRED)

find_ups_package(
TARGET_NAME deps::log4cpp
INC_VAR LOG4CPP_INC
LIB_VAR LOG4CPP_LIB
LIBS log4cpp
REQUIRED)

find_ups_package(
TARGET_NAME deps::edepsim
INC_VAR EDEPSIM_INC
LIB_VAR EDEPSIM_LIB
LIBS edepsim
INC_SUFFIX EDepSim
REQUIRED)

find_ups_package(
TARGET_NAME deps::boost_po
INC_VAR BOOST_INC
LIB_VAR BOOST_LIB
LIBS boost_program_options
REQUIRED)

find_ups_package(
TARGET_NAME deps::fhiclcpp
INC_VAR FHICLCPP_INC
LIB_VAR FHICLCPP_LIB
LIBS fhiclcpp fhiclcpp_types
REQUIRED)

find_ups_package(
TARGET_NAME deps::duneanaobj
INC_VAR DUNEANAOBJ_INC
LIB_VAR DUNEANAOBJ_LIB
LIBS duneanaobj_StandardRecord duneanaobj_StandardRecordFlat
REQUIRED)

find_ups_package(
TARGET_NAME deps::tbb
LIB_VAR TBB_LIB
LIBS tbb
REQUIRED)

find_ups_package(
TARGET_NAME deps::gsl
LIB_VAR GSL_LIB
LIBS gsl gslcblas
REQUIRED)

find_ups_package(
TARGET_NAME deps::lhapdf
LIB_VAR LHAPDF_LIB
LIBS LHAPDF
REQUIRED)

find_ups_package(TARGET_NAME deps::nlohmann INC_VAR NLOHMANN_JSON_INC)

find_ups_package(TARGET_NAME deps::srproxy INC_VAR SRPROXY_INC)

find_library(
CETLIB_LIB_PATH
NAMES cetlib
PATHS "$ENV{CETLIB_LIB}"
NO_DEFAULT_PATH)

find_library(
CETLIB_EXCEPT_LIB_PATH
NAMES cetlib_except
PATHS "$ENV{CETLIB_EXCEPT_LIB}"
NO_DEFAULT_PATH)

add_library(deps::cetlib INTERFACE IMPORTED)

set_target_properties(
deps::cetlib
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"$ENV{CETLIB_INC};$ENV{CETLIB_EXCEPT_INC}"
INTERFACE_LINK_LIBRARIES
"${CETLIB_LIB_PATH};${CETLIB_EXCEPT_LIB_PATH}")

find_library(
LIBXML2_LIB_PATH
NAMES xml2
PATHS "$ENV{LIBXML2_FQ_DIR}/lib"
NO_DEFAULT_PATH)
add_library(deps::libxml2 INTERFACE IMPORTED)
set_target_properties(deps::libxml2 PROPERTIES INTERFACE_LINK_LIBRARIES
"${LIBXML2_LIB_PATH}")

find_library(
PYTHIA6_LIB_PATH
NAMES Pythia6
PATHS "$ENV{PYTHIA6_LIBRARY}"
NO_DEFAULT_PATH)
add_library(deps::pythia6 INTERFACE IMPORTED)
set_target_properties(deps::pythia6 PROPERTIES INTERFACE_LINK_LIBRARIES
"${PYTHIA6_LIB_PATH}")

find_library(
CURL_LIB_PATH
NAMES curl
PATHS /usr/lib64
NO_DEFAULT_PATH)
add_library(deps::curl INTERFACE IMPORTED)
set_target_properties(
deps::curl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "/usr/include/curl"
INTERFACE_LINK_LIBRARIES "${CURL_LIB_PATH}")

# SANDReco — optional, auto-detected from environment (both modes)
if(DEFINED ENV{SANDRECO_INC} OR DEFINED ENV{SANDRECO_LIB})
set(SAND_ENABLED TRUE)
find_library(
SANDRECO_LIB_PATH
NAMES Struct
PATHS "$ENV{SANDRECO_LIB}"
NO_DEFAULT_PATH)
add_library(deps::sand INTERFACE IMPORTED)
set_target_properties(
deps::sand PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$ENV{SANDRECO_INC}"
INTERFACE_LINK_LIBRARIES "${SANDRECO_LIB_PATH}")
message(STATUS "SANDReco: enabled (SANDRECO_INC=$ENV{SANDRECO_INC})")
else()
set(SAND_ENABLED FALSE)
add_library(deps::sand INTERFACE IMPORTED) # no-op target for unconditional
# linking
message(STATUS "SANDReco: disabled (SANDRECO_INC/LIB not set)")
endif()

add_subdirectory(src)
62 changes: 0 additions & 62 deletions Makefile

This file was deleted.

57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,62 @@ To add variables and inspect what is set and how, check `src/Params.h`.


## Building
Once you've set up your environment, it's just a matter of typing

### Build environment

The build requires the UPS dependencies provided by the Fermilab software stack.
The recommended way to get a compatible environment is via the Singularity image:

```
singularity shell --bind /cvmfs /cvmfs/singularity.opensciencegrid.org/fermilab/fnal-wn-sl7:latest
```

Once inside the container, source the setup script as usual before configuring:

```
make
source ndcaf_setup.sh {prof|debug}
```
in the `ND_CAFMaker` folder, which goes through and builds the objects, library and single `makeCAF` executable.

### CMake configuration

Once you've set up your environment, configure and build with CMake:

```
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build
```

The build products are installed under `build/` by default. The `makeCAF` executable will be at `build/bin/makeCAF`.

### CMake build options

| Option | Default | Description |
|--------|---------|-------------|
| `ENABLE_TMS` | `ON` | Enable TMS reconstruction branch filler |
| `ENABLE_TESTEXE` | `OFF` | Build the `testHDF` test executable |
| `CMAKE_BUILD_TYPE` | — | Set to `Debug` or `Release` (overrides the `-g -O2` defaults) |

Example: disable TMS and build the test executable:

```
cmake -S . -B build -DENABLE_TMS=OFF -DENABLE_TESTEXE=ON
cmake --build build
```

### Installing

To install the library and executables to a custom prefix:

```
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install
cmake --build build --target install
```

This will place:
- `libND_CAFMaker.so` → `<prefix>/lib/`
- `makeCAF` (and optionally `testHDF`) → `<prefix>/bin/`

If no `CMAKE_INSTALL_PREFIX` is given, the default system prefix (`/usr/local`) is used.

# Running
There is currently only one main executable, `makeCAF`, which is controlled entirely by the input `fhicl` file. To run with the `fhicl` file that was specified under `Inputs`, do
Expand Down
Loading
Loading