Skip to content
Snippets Groups Projects
Commit 76c414ed authored by Felix Weiglhofer's avatar Felix Weiglhofer
Browse files

algo: Add skeleton for cbmreco app.

parent b9d061ac
No related branches found
No related tags found
1 merge request!1159algo: Add skeleton for cbmreco app.
Pipeline #22361 failed
...@@ -9,7 +9,9 @@ set(DEVICE_SRCS ...@@ -9,7 +9,9 @@ set(DEVICE_SRCS
set(SRCS set(SRCS
${DEVICE_SRCS} ${DEVICE_SRCS}
base/Options.cxx
evbuild/EventBuilder.cxx evbuild/EventBuilder.cxx
global/Reco.cxx
trigger/TimeClusterTrigger.cxx trigger/TimeClusterTrigger.cxx
evselector/DigiEventSelector.cxx evselector/DigiEventSelector.cxx
detectors/sts/StsHitfinderChain.cxx detectors/sts/StsHitfinderChain.cxx
...@@ -32,6 +34,7 @@ target_include_directories(Algo ...@@ -32,6 +34,7 @@ target_include_directories(Algo
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/base ${CMAKE_CURRENT_SOURCE_DIR}/base
${CMAKE_CURRENT_SOURCE_DIR}/evbuild ${CMAKE_CURRENT_SOURCE_DIR}/evbuild
${CMAKE_CURRENT_SOURCE_DIR}/global
${CMAKE_CURRENT_SOURCE_DIR}/trigger ${CMAKE_CURRENT_SOURCE_DIR}/trigger
${CMAKE_CURRENT_SOURCE_DIR}/evselector ${CMAKE_CURRENT_SOURCE_DIR}/evselector
${CMAKE_CURRENT_SOURCE_DIR}/detectors/sts ${CMAKE_CURRENT_SOURCE_DIR}/detectors/sts
...@@ -45,9 +48,10 @@ target_link_libraries(Algo ...@@ -45,9 +48,10 @@ target_link_libraries(Algo
PUBLIC OnlineData PUBLIC OnlineData
ROOT::GenVector ROOT::GenVector
GSL GSL
Boost::program_options
xpu
INTERFACE FairLogger::FairLogger INTERFACE FairLogger::FairLogger
external::fles_ipc external::fles_ipc
xpu
) )
target_compile_definitions(Algo PUBLIC NO_ROOT) target_compile_definitions(Algo PUBLIC NO_ROOT)
xpu_attach(Algo ${DEVICE_SRCS}) xpu_attach(Algo ${DEVICE_SRCS})
......
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#ifndef CBM_ALGO_BASE_CHAINCONTEXT_H
#define CBM_ALGO_BASE_CHAINCONTEXT_H
#include "Options.h"
namespace cbm::algo
{
struct ChainContext {
Options opts;
};
} // namespace cbm::algo
#endif
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "Options.h"
#include <boost/program_options.hpp>
#include <iostream>
using namespace cbm::algo;
Options::Options(int argc, char** argv)
{
namespace po = boost::program_options;
po::options_description required("Required options");
// clang-format off
required.add_options()
("param-dir,p", po::value<std::string>(&fParamsDir)->value_name("<folder>")->required(),
"read program options from this folder")
("input-locator,i", po::value<std::string>(&fInputLocator)->value_name("<locator>")->required(),
"URI specifying input timeslice source")
;
// clang-format on
po::options_description generic("Other options");
// clang-format off
generic.add_options()
("device,d", po::value<std::string>(&fDevice)->default_value("cpu")->value_name("<device>"),
"select device (cpu, cuda0, cuda1, hip0, ...)")
("log-level,l", po::value<std::string>(&fLogLevel)->default_value("info")->value_name("<level>"),
"set log level (debug, info, warning, error, fatal)")
("num-ts,n", po::value<int>(&fNumTimeslices)->default_value(-1)->value_name("<num>"),
"Stop after <num> timeslices (-1 = all)")
("skip-ts,s", po::value<int>(&fSkipTimeslices)->default_value(0)->value_name("<num>"),
"Skip first <num> timeslices")
("times,t", po::bool_switch(&fCollectKernelTimes)->default_value(false),
"print kernel times")("help,h", "produce help message")
;
// clang-format on
po::options_description cmdline_options;
cmdline_options.add(required).add(generic);
po::variables_map vm;
po::command_line_parser parser {argc, argv};
parser.options(cmdline_options);
po::store(parser.run(), vm);
if (vm.count("help")) {
std::cerr << cmdline_options << std::endl;
std::exit(0);
}
try {
po::notify(vm);
}
catch (const po::required_option& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << cmdline_options << std::endl;
std::exit(1);
}
}
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#ifndef CBM_ALGO_BASE_OPTIONS_H
#define CBM_ALGO_BASE_OPTIONS_H
#include <filesystem>
#include <string>
namespace cbm::algo
{
class Options {
public:
Options() = default;
Options(int argc, char** argv);
std::filesystem::path ParamsDir() const { return fParamsDir; }
const std::string& InputLocator() const { return fInputLocator; }
const std::string& LogLevel() const { return fLogLevel; }
const std::string& Device() const { return fDevice; }
bool CollectKernelTimes() const { return fCollectKernelTimes; }
int NumTimeslices() const { return fNumTimeslices; }
int SkipTimeslices() const { return fSkipTimeslices; }
private:
std::string fParamsDir; // TODO: can we make this a std::path?
std::string fInputLocator;
std::string fLogLevel;
std::string fDevice;
bool fCollectKernelTimes = false;
int fNumTimeslices = -1;
int fSkipTimeslices = 0;
};
} // namespace cbm::algo
#endif
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#ifndef CBM_ALGO_BASE_SUBCHAIN_H
#define CBM_ALGO_BASE_SUBCHAIN_H
#include <gsl/pointers>
#include "ChainContext.h"
namespace cbm::algo
{
class SubChain {
public:
void SetContext(ChainContext* ctx) { fContext = ctx; }
const Options& Opts() const { return gsl::make_not_null(fContext)->opts; }
private:
ChainContext* fContext = nullptr;
};
} // namespace cbm::algo
#endif
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "Reco.h"
using namespace cbm::algo;
Reco::Reco() {}
Reco::~Reco() {}
void Reco::Init(const Options&) {}
void Reco::Run() {}
void Reco::Finalize() {}
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#ifndef CBM_ALGO_GLOBAL_RECO_H
#define CBM_ALGO_GLOBAL_RECO_H
#include "SubChain.h"
namespace fles
{
class Timeslice;
} // namespace fles
namespace cbm::algo
{
class Options;
class Reco : SubChain {
public:
Reco();
~Reco();
Reco(const Reco&) = delete;
Reco& operator=(const Reco&) = delete;
Reco(Reco&&) = delete;
Reco& operator=(Reco&&) = delete;
void Init(const Options&);
void Run();
void Finalize();
private:
bool fInitialized = false;
ChainContext fContext;
};
} // namespace cbm::algo
#endif
add_subdirectory(cbmreco)
add_subdirectory(cbmreco_fairrun) add_subdirectory(cbmreco_fairrun)
set(SRCS main.cxx)
add_executable(cbmreco ${SRCS})
target_link_libraries(cbmreco Algo)
install(TARGETS cbmreco DESTINATION bin)
/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer] */
#include "Options.h"
#include "Reco.h"
int main(int argc, char** argv)
{
cbm::algo::Options opts {argc, argv};
cbm::algo::Reco reco {};
reco.Init(opts);
reco.Run();
reco.Finalize();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment