Skip to content

Commit

Permalink
add magic_enum
Browse files Browse the repository at this point in the history
  • Loading branch information
YanzhaoW committed Jan 13, 2025
1 parent 4ec10a8 commit 53b5ccc
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 16 deletions.
1 change: 1 addition & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def requirements(self):
self.requires("gtest/cci.20210126")
self.requires("nlohmann_json/3.11.2")
self.requires("yaml-cpp/0.8.0")
self.requires("magic_enum/0.9.7")

def generate(self):
tc = CMakeToolchain(self)
Expand Down
10 changes: 7 additions & 3 deletions neuland/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
##############################################################################
# cmake-format: on

add_subdirectory(calibration)
add_subdirectory(clustering)
Expand All @@ -24,6 +25,9 @@ add_subdirectory(shared)
add_subdirectory(simulation)
add_subdirectory(test)
add_subdirectory(unpack)
add_subdirectory(application)
add_subdirectory(executables)
add_subdirectory(geobase)
add_subdirectory(geobase)

if(CONAN_ENABLED)
add_subdirectory(application)
add_subdirectory(executables)
endif()
3 changes: 3 additions & 0 deletions neuland/application/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
find_package(magic_enum REQUIRED)

add_library(R3BNeulandApp SHARED R3BNeulandAnalysisApp.cxx R3BNeulandApp.cxx
R3BNeulandAppOptionJson.cxx R3BNeulandSimApp.cxx)

target_include_directories(R3BNeulandApp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(
R3BNeulandApp
PRIVATE magic_enum::magic_enum
PUBLIC R3BNeulandDigitizing
nlohmann_json::nlohmann_json
R3BNeulandReconstruction
Expand Down
9 changes: 9 additions & 0 deletions neuland/application/R3BNeulandAnalysisApp.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "R3BNeulandSimCalToCal.h"
#include <CLI/CLI.hpp>
#include <FairRunAna.h>
#include <R3BDigitizingChannelMock.h>
Expand Down Expand Up @@ -128,6 +129,14 @@ namespace R3B::Neuland
else
{
task_option.cluster_finder.enable = false;
task_option.sim_cal_to_cal.enable = false;
}

if (task_option.sim_cal_to_cal.enable)
{
auto task = std::make_unique<R3B::Neuland::SimCal2Cal>();
task->SetName(task_option.sim_cal_to_cal.name.c_str());
run->AddTask(task.release());
}

if (task_option.hit_monitor.enable)
Expand Down
19 changes: 17 additions & 2 deletions neuland/application/R3BNeulandAppOptionJson.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "R3BNeulandAppOptionJson.h"
#include <fmt/format.h>
#include <magic_enum/magic_enum.hpp>

using json = nlohmann::ordered_json;

Expand Down Expand Up @@ -179,7 +180,7 @@ namespace R3B::Neuland
{ "channel", option.channel },
{ "paddle", option.paddle },
{ "par", option.tamex_par },
{ "pileup-strategy", option.pileup_strategy },
{ "pileup-strategy", magic_enum::enum_name(option.pileup_strategy) },
{ "enable-sim-cal", option.enable_sim_cal },
{ "enable-hit-par", option.enable_hit_par },
{ "name", option.name } };
Expand All @@ -192,9 +193,23 @@ namespace R3B::Neuland
json_obj.at("channel").get_to(option.channel);
json_obj.at("paddle").get_to(option.paddle);
json_obj.at("par").get_to(option.tamex_par);
json_obj.at("pileup-strategy").get_to(option.pileup_strategy);
json_obj.at("enable-sim-cal").get_to(option.enable_sim_cal);
json_obj.at("enable-hit-par").get_to(option.enable_hit_par);

// parse enum string
auto enum_name = std::string{};
json_obj.at("pileup-strategy").get_to(enum_name);
auto enum_val = magic_enum::enum_cast<Digitizing::Neuland::Tamex::PeakPileUpStrategy>(
enum_name, magic_enum::case_insensitive);
if (enum_val.has_value())
{
option.pileup_strategy = enum_val.value();
}
else
{
throw R3B::logic_error(fmt::format("Cannot parse the enum string {:?} to PeakPileUpStrategy enum class. "
"Please check if the enum string is correct!"));
}
}

template <>
Expand Down
11 changes: 7 additions & 4 deletions neuland/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
# cmake-format: on

add_subdirectory(legacy)
add_subdirectory(mille)
add_subdirectory(share)
add_subdirectory(map_to_cal)
add_subdirectory(cal_to_hit)

if(CONAN_ENABLED)
add_subdirectory(mille)
add_subdirectory(share)
add_subdirectory(map_to_cal)
add_subdirectory(cal_to_hit)
endif()

add_library(R3BNeulandCalibration INTERFACE)
target_link_libraries(
Expand Down
9 changes: 3 additions & 6 deletions neuland/digitizing/NeulandSimCalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "TObject.h"
namespace R3B::Neuland
{

struct SimCalData : public TObject
{
int bar_module{}; // ns
Expand All @@ -13,13 +12,11 @@ namespace R3B::Neuland
double tot_r{}; // ns
SimCalData() = default;
SimCalData(Int_t paddleid, double totL, double totR, double tleL, double tleR)
:

bar_module{ paddleid }
, tot_l{ totL }
, tot_r{ totR }
: bar_module{ paddleid }
, let_l{ tleL }
, let_r{ tleR }
, tot_l{ totL }
, tot_r{ totR }
{
}
ClassDefNV(SimCalData, 2);
Expand Down
2 changes: 1 addition & 1 deletion neuland/geobase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ endif()

add_library(R3BNeulandGeoBase SHARED R3BNeulandGeoCreator.cxx)
target_include_directories(R3BNeulandGeoBase PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(R3BNeulandGeoBase PUBLIC R3BNeulandShared)
target_link_libraries(R3BNeulandGeoBase PUBLIC R3BNeulandShared GeoBase)

0 comments on commit 53b5ccc

Please sign in to comment.