Skip to content
Snippets Groups Projects
Commit a9510693 authored by Andreas Salzburger's avatar Andreas Salzburger
Browse files

Merge branch 'examples-compilation-units-round2' into 'master'

Examples compilation units round 2

See merge request !170
parents 3e8e5461 2816372f
No related branches found
No related tags found
1 merge request!170Examples compilation units round 2
Pipeline #1248681 passed
Showing
with 872 additions and 253 deletions
add_library(
ACTFWDigitization SHARED
src/DigitizationOptions.cpp
src/DigitizationAlgorithm.cpp)
target_include_directories(
ACTFWDigitization
......
......@@ -8,12 +8,9 @@
#pragma once
#include <iostream>
#include "ACTFW/Utilities/Options.hpp"
#include "Acts/Utilities/Units.hpp"
#include "DigitizationAlgorithm.hpp"
#include "ACTFW/Utilities/OptionsFwd.hpp"
namespace po = boost::program_options;
#include "ACTFW/Digitization/DigitizationAlgorithm.hpp"
namespace FW {
......@@ -22,41 +19,16 @@ namespace Options {
/// @brief Digitization options
/// Adds specific digitization options to the boost::program_options
///
/// @tparam aopt_t Type of the options object (API bound to boost)
///
/// @param [in] opt_t The options object where the specific digitization
/// options are attached to
template <typename aopt_t>
void
addDigitizationOptions(aopt_t& opt)
{
opt.add_options()("digi-spacepoints",
po::value<std::string>()->default_value("space-points"),
"Collection name of the produced space points.")(
"digi-clusters",
po::value<std::string>()->default_value("clusters"),
"Collection name of the produced clustes.")(
"digi-resolution-file",
po::value<std::string>()->default_value(""),
"Name of the resolution file (root format).");
}
addDigitizationOptions(boost::program_options::options_description& opt);
///@brief Read the digitization options and return a Config object
///
///@tparam omap_t Type of the options map
///@param vm the options map to be read out
template <typename omap_t>
DigitizationAlgorithm::Config
readDigitizationConfig(const omap_t& vm)
{
// create a config
DigitizationAlgorithm::Config digiConfig;
digiConfig.clusterCollection
= vm["digi-clusters"].template as<std::string>();
digiConfig.resolutionFile
= vm["digi-resolution-file"].template as<std::string>();
// and return the config
return digiConfig;
}
readDigitizationConfig(const boost::program_options::variables_map& vm);
} // namespace Options
} // namespace FW
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "ACTFW/Digitization/DigitizationOptions.hpp"
#include "ACTFW/Digitization/DigitizationAlgorithm.hpp"
#include <boost/program_options.hpp>
namespace po = boost::program_options;
namespace FW {
namespace Options {
void
addDigitizationOptions(boost::program_options::options_description& opt)
{
opt.add_options()("digi-spacepoints",
po::value<std::string>()->default_value("space-points"),
"Collection name of the produced space points.")(
"digi-clusters",
po::value<std::string>()->default_value("clusters"),
"Collection name of the produced clustes.")(
"digi-resolution-file",
po::value<std::string>()->default_value(""),
"Name of the resolution file (root format).");
}
DigitizationAlgorithm::Config
readDigitizationConfig(const boost::program_options::variables_map& vm)
{
// create a config
DigitizationAlgorithm::Config digiConfig;
digiConfig.clusterCollection
= vm["digi-clusters"].template as<std::string>();
digiConfig.resolutionFile
= vm["digi-resolution-file"].template as<std::string>();
// and return the config
return digiConfig;
}
} // namespace Options
} // namespace FW
add_library(
ACTFWFatras INTERFACE)
add_library(ACTFWFatras SHARED src/FatrasOptions.cpp)
target_include_directories(
ACTFWFatras
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
ACTFWFatras
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>)
target_link_libraries(
ACTFWFatras
INTERFACE ActsCore ACTFramework)
ACTFWFatras
PUBLIC ActsCore FatrasCore ACTFramework)
# interface libraries do not exist in the filesystem; no installation needed
install(
TARGETS ACTFWFatras
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
......@@ -8,15 +8,16 @@
#pragma once
#include <iostream>
#include "ACTFW/Utilities/Options.hpp"
//#include "ACTFW/Utilities/Options.hpp"
#include "Acts/Utilities/Units.hpp"
#include "Fatras/Kernel/SelectorList.hpp"
#include "Fatras/Selectors/ChargeSelectors.hpp"
#include "Fatras/Selectors/KinematicCasts.hpp"
#include "Fatras/Selectors/SelectorHelpers.hpp"
#include "FatrasAlgorithm.hpp"
namespace po = boost::program_options;
#include <iostream>
#include "ACTFW/Utilities/OptionsFwd.hpp"
namespace FW {
......@@ -26,39 +27,10 @@ namespace Options {
///
/// Adding Fatras specific options to the Options package
///
/// @tparam aopt_t Type of the options object (API bound to boost)
///
/// @param [in] opt_t The options object where the specific digitization
/// options are attached to
template <typename aopt_t>
void
addFatrasOptions(aopt_t& opt)
{
opt.add_options()(
"fatras-sim-particles",
po::value<std::string>()->default_value("fatras-particles"),
"The collection of simulated particles.")(
"fatras-sim-hits",
po::value<std::string>()->default_value("fatras-hits"),
"The collection of simulated hits")(
"fatras-em-ionisation",
po::value<bool>()->default_value(true),
"Switch on ionisiation loss of charged particles")(
"fatras-em-radiation",
po::value<bool>()->default_value(true),
"Switch on radiation for charged particles")(
"fatras-em-scattering",
po::value<bool>()->default_value(true),
"Switch on multiple scattering")(
"fatras-em-conversions",
po::value<bool>()->default_value(false),
"Switch on gamma conversions")("fatras-had-interaction",
po::value<bool>()->default_value(false),
"Switch on hadronic interaction")(
"fatras-debug-output",
po::value<bool>()->default_value(false),
"Switch on debug output on/off");
}
addFatrasOptions(boost::program_options::options_description& opt);
/// @brief read the fatras specific options and return a Config file
///
......@@ -68,6 +40,7 @@ namespace Options {
typename FatrasAlgorithm<simulator_t, event_collection_t>::Config
readFatrasConfig(const AMAP& vm, simulator_t& simulator)
{
using namespace Acts::UnitLiterals;
// Create a config
typename FatrasAlgorithm<simulator_t, event_collection_t>::Config
fatrasConfig(std::move(simulator));
......@@ -89,12 +62,10 @@ namespace Options {
typedef Fatras::Min<Fatras::casts::E> NMinE;
simulator.chargedSelector.template get<CMaxEtaAbs>().valMax = 5.;
simulator.chargedSelector.template get<CMinPt>().valMin
= 100. * Acts::units::_MeV;
simulator.chargedSelector.template get<CMinPt>().valMin = 100._MeV;
simulator.neutralSelector.template get<NMaxEtaAbs>().valMax = 5.;
simulator.neutralSelector.template get<NMinE>().valMin
= 100. * Acts::units::_MeV;
simulator.neutralSelector.template get<NMinE>().valMin = 100._MeV;
// and return the config
return fatrasConfig;
......
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "ACTFW/Fatras/FatrasOptions.hpp"
#include <boost/program_options.hpp>
namespace po = boost::program_options;
namespace FW {
namespace Options {
void
addFatrasOptions(boost::program_options::options_description& opt)
{
opt.add_options()(
"fatras-sim-particles",
po::value<std::string>()->default_value("fatras-particles"),
"The collection of simulated particles.")(
"fatras-sim-hits",
po::value<std::string>()->default_value("fatras-hits"),
"The collection of simulated hits")(
"fatras-em-ionisation",
po::value<bool>()->default_value(true),
"Switch on ionisiation loss of charged particles")(
"fatras-em-radiation",
po::value<bool>()->default_value(true),
"Switch on radiation for charged particles")(
"fatras-em-scattering",
po::value<bool>()->default_value(true),
"Switch on multiple scattering")(
"fatras-em-conversions",
po::value<bool>()->default_value(false),
"Switch on gamma conversions")("fatras-had-interaction",
po::value<bool>()->default_value(false),
"Switch on hadronic interaction")(
"fatras-debug-output",
po::value<bool>()->default_value(false),
"Switch on debug output on/off");
}
} // namespace Options
} // namespace FW
add_library(
ACTFWFitting INTERFACE)
ACTFWFitting SHARED
src/FittingOptions.cpp
src/FittingAlgorithm.cpp)
target_include_directories(
ACTFWFitting
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
ACTFWFitting
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>)
target_link_libraries(
ACTFWFitting
INTERFACE ActsCore ACTFramework)
ACTFWFitting
PUBLIC ActsCore ACTFramework)
# interface libraries do not exist in the filesystem; no installation needed
install(
TARGETS ACTFWFitting
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
......@@ -8,53 +8,50 @@
#pragma once
#include <iostream>
#include <map>
#include <functional>
#include <memory>
#include <random>
#include <stdexcept>
#include <string>
#include <vector>
#include "ACTFW/EventData/Barcode.hpp"
#include "ACTFW/EventData/DataContainers.hpp"
#include "ACTFW/EventData/SimHit.hpp"
#include "ACTFW/EventData/SimParticle.hpp"
#include "ACTFW/EventData/SimSourceLink.hpp"
#include "ACTFW/EventData/SimVertex.hpp"
#include "ACTFW/Framework/BareAlgorithm.hpp"
#include "ACTFW/Framework/ProcessCode.hpp"
#include "ACTFW/Framework/RandomNumbers.hpp"
#include "ACTFW/Framework/WhiteBoard.hpp"
#include "Acts/EventData/Measurement.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/EventData/TrackState.hpp"
#include "Acts/Fitter/KalmanFitter.hpp"
#include "Acts/Geometry/GeometryID.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "Acts/Utilities/ParameterDefinitions.hpp"
namespace FW {
template <typename kalman_Fitter_t>
class RandomNumbers;
class FittingAlgorithm : public BareAlgorithm
{
public:
// A few initialisations and definitionas
using Identifier = Data::SimSourceLink;
using TrackState = Acts::TrackState<Identifier, Acts::BoundParameters>;
using ResultType
= Acts::KalmanFitterResult<Identifier, Acts::BoundParameters>;
using StartParameters = Acts::CurvilinearParameters;
/// Nested configuration struct
struct Config
{
Config(kalman_Fitter_t fitter) : kFitter(std::move(fitter)) {}
/// input hit collection
std::string simulatedHitCollection;
/// input event collection
std::string simulatedEventCollection;
/// output track collection
std::string trackCollection;
/// kalmanFitter instance
kalman_Fitter_t kFitter;
std::string trackCollection = "";
/// Type erased fit function
std::function<ResultType(std::vector<Identifier>&,
const StartParameters&,
const Acts::KalmanFitterOptions&)>
fitFunction;
/// FW random number service
std::shared_ptr<RandomNumbers> randomNumberSvc = nullptr;
/// Gaussian sigma used to smear the truth track parameter
......@@ -82,5 +79,3 @@ private:
};
} // namespace FW
#include "FittingAlgorithm.ipp"
......@@ -8,11 +8,11 @@
#pragma once
#include <iostream>
#include "ACTFW/Utilities/Options.hpp"
#include "FittingAlgorithm.hpp"
#include "ACTFW/Fitting/FittingAlgorithm.hpp"
#include "ACTFW/Utilities/OptionsFwd.hpp"
namespace po = boost::program_options;
#include <iostream>
namespace FW {
......@@ -22,62 +22,17 @@ namespace Options {
///
/// Adding Fitting specific options to the Options package
///
/// @tparam aopt_t Type of the options object (API bound to boost)
///
/// @param [in] opt_t The options object where the specific digitization
/// options are attached to
template <typename aopt_t>
void
addFittingOptions(aopt_t& opt)
{
opt.add_options()(
"fatras-sim-particles",
po::value<std::string>()->default_value("fatras-particles"),
"The collection of simulated particles.")(
"fatras-sim-hits",
po::value<std::string>()->default_value("fatras-hits"),
"The collection of simulated hits")(
"fitted-tracks",
po::value<std::string>()->default_value("fitted-tracks"),
"The collection of output tracks")(
"initial-parameter-sigma",
po::value<read_range>()->multitoken()->default_value(
{10., 10., 0.02, 0.02, 1}),
"Gaussian sigma used to smear the truth track parameter Loc0 [um], "
"Loc1 [um], phi, theta, q/p [-q/(p*p)*GeV]")(
"measurement-sigma",
po::value<read_range>()->multitoken()->default_value({30., 30.}),
"Gaussian sigma used to smear the truth hit Loc0 [um], Loc1 [um]");
}
addFittingOptions(boost::program_options::options_description& opt);
/// @brief read the fitter specific options and return a Config file
///
///@tparam omap_t Type of the options map
///@param vm the options map to be read out
template <typename AMAP, typename kalman_Fitter_t>
typename FittingAlgorithm<kalman_Fitter_t>::Config
readFittingConfig(const AMAP& vm, kalman_Fitter_t fitter)
{
// Create a config
typename FittingAlgorithm<kalman_Fitter_t>::Config fittingConfig(
std::move(fitter));
// set the collections
fittingConfig.simulatedHitCollection
= vm["fatras-sim-hits"].template as<std::string>();
fittingConfig.simulatedEventCollection
= vm["fatras-sim-particles"].template as<std::string>();
fittingConfig.trackCollection
= vm["fitted-tracks"].template as<std::string>();
fittingConfig.parameterSigma
= vm["initial-parameter-sigma"].template as<read_range>();
fittingConfig.measurementSigma
= vm["measurement-sigma"].template as<read_range>();
// and return the config
return fittingConfig;
}
void
readFittingConfig(const boost::program_options::variables_map& vm,
FittingAlgorithm::Config& fittingConfig);
} // namespace Options
} // namespace FW
......@@ -6,10 +6,25 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
template <typename kalman_Fitter_t>
FW::FittingAlgorithm<kalman_Fitter_t>::FittingAlgorithm(
Config cfg,
Acts::Logging::Level level)
#include "ACTFW/Fitting/FittingAlgorithm.hpp"
#include "ACTFW/EventData/SimHit.hpp"
#include "ACTFW/EventData/SimParticle.hpp"
#include "ACTFW/EventData/SimVertex.hpp"
#include "ACTFW/Framework/RandomNumbers.hpp"
#include "ACTFW/Framework/WhiteBoard.hpp"
#include "Acts/EventData/Measurement.hpp"
#include "Acts/Geometry/GeometryID.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/ParameterDefinitions.hpp"
#include <iostream>
#include <map>
#include <random>
#include <stdexcept>
FW::FittingAlgorithm::FittingAlgorithm(Config cfg, Acts::Logging::Level level)
: FW::BareAlgorithm("FittingAlgorithm", level), m_cfg(std::move(cfg))
{
if (m_cfg.simulatedHitCollection.empty()) {
......@@ -21,10 +36,8 @@ FW::FittingAlgorithm<kalman_Fitter_t>::FittingAlgorithm(
}
}
template <typename kalman_Fitter_t>
FW::ProcessCode
FW::FittingAlgorithm<kalman_Fitter_t>::execute(
const FW::AlgorithmContext& context) const
FW::FittingAlgorithm::execute(const FW::AlgorithmContext& context) const
{
// Create a random number generator
FW::RandomEngine generator = m_cfg.randomNumberSvc->spawnGenerator(context);
......@@ -158,8 +171,7 @@ FW::FittingAlgorithm<kalman_Fitter_t>::execute(
Acts::Vector3D rPos = pos + displaced;
// then create the start parameters using the prepared momentum and position
Acts::SingleCurvilinearTrackParameters<Acts::ChargedPolicy> rStart(
cov, rPos, rMom, q, 0);
StartParameters rStart(cov, rPos, rMom, q, 0);
// set the target surface
const Acts::Surface* rSurface = &rStart.referenceSurface();
......@@ -171,7 +183,9 @@ FW::FittingAlgorithm<kalman_Fitter_t>::execute(
rSurface);
// perform the fit with KalmanFitter
auto fittedResult = m_cfg.kFitter.fit(sourceLinks, rStart, kfOptions);
// auto fittedResult = m_cfg.kFitter.fit(sourceLinks, rStart, kfOptions);
ACTS_DEBUG("Invoke fitter");
auto fittedResult = m_cfg.fitFunction(sourceLinks, rStart, kfOptions);
ACTS_DEBUG("Finish the fitting.");
// get the fitted parameters
......
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "ACTFW/Fitting/FittingOptions.hpp"
#include "ACTFW/Utilities/Options.hpp"
#include <boost/program_options.hpp>
namespace po = boost::program_options;
namespace FW {
namespace Options {
void
addFittingOptions(boost::program_options::options_description& opt)
{
opt.add_options()(
"fatras-sim-particles",
po::value<std::string>()->default_value("fatras-particles"),
"The collection of simulated particles.")(
"fatras-sim-hits",
po::value<std::string>()->default_value("fatras-hits"),
"The collection of simulated hits")(
"fitted-tracks",
po::value<std::string>()->default_value("fitted-tracks"),
"The collection of output tracks")(
"initial-parameter-sigma",
po::value<read_range>()->multitoken()->default_value(
{10., 10., 0.02, 0.02, 1}),
"Gaussian sigma used to smear the truth track parameter Loc0 [um], "
"Loc1 [um], phi, theta, q/p [-q/(p*p)*GeV]")(
"measurement-sigma",
po::value<read_range>()->multitoken()->default_value({30., 30.}),
"Gaussian sigma used to smear the truth hit Loc0 [um], Loc1 [um]");
}
void
readFittingConfig(const boost::program_options::variables_map& vm,
FittingAlgorithm::Config& fittingConfig)
{
// set the collections
fittingConfig.simulatedHitCollection
= vm["fatras-sim-hits"].template as<std::string>();
fittingConfig.simulatedEventCollection
= vm["fatras-sim-particles"].template as<std::string>();
fittingConfig.trackCollection
= vm["fitted-tracks"].template as<std::string>();
fittingConfig.parameterSigma
= vm["initial-parameter-sigma"].template as<read_range>();
fittingConfig.measurementSigma
= vm["measurement-sigma"].template as<read_range>();
}
} // namespace Options
} // namespace FW
......@@ -16,6 +16,7 @@
#include "Acts/MagneticField/ConstantBField.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/MagneticField/MagneticFieldContext.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/Units.hpp"
#include <random>
......@@ -161,15 +162,8 @@ main(int argc, char* argv[])
// Why does this need number-of-events? If it really does emulate
// per-event access patterns this should be switched to a proper
// Sequencer-based tool. Otherwise it should be removed.
auto nEvents = FW::Options::readSequencerConfig(vm).events;
auto bField = FW::Options::readBField(vm);
auto field2D = std::get<std::shared_ptr<InterpolatedBFieldMap2D>>(bField);
auto field3D = std::get<std::shared_ptr<InterpolatedBFieldMap3D>>(bField);
if (!field2D && !field3D) {
std::cout << "Bfield map could not be read. Exiting." << std::endl;
return EXIT_FAILURE;
}
auto nEvents = FW::Options::readSequencerConfig(vm).events;
auto bFieldVar = FW::Options::readBField(vm);
// Get the phi and eta range
auto phir = vm["bf-phi-range"].as<read_range>();
......@@ -189,48 +183,37 @@ main(int argc, char* argv[])
double theta_step = theta_span / theta_steps;
double access_step = track_length / access_steps;
// write it out
if (field2D) {
// the 2-dimensional field case
// Step-wise access pattern
accessStepWise<InterpolatedBFieldMap2D>(*field2D,
magFieldContext,
nEvents,
theta_steps,
thetar[0],
theta_step,
phi_steps,
phir[0],
phi_step,
access_steps,
access_step);
// Random access pattern
accessRandom<InterpolatedBFieldMap2D>(*field2D,
magFieldContext,
nEvents * theta_steps * phi_steps
* access_steps,
track_length);
} else {
// the 3-dimensional field case
// Step-wise access pattern
accessStepWise<InterpolatedBFieldMap3D>(*field3D,
magFieldContext,
nEvents,
theta_steps,
thetar[0],
theta_step,
phi_steps,
phir[0],
phi_step,
access_steps,
access_step);
// Random access pattern
accessRandom<InterpolatedBFieldMap3D>(*field3D,
magFieldContext,
nEvents * theta_steps * phi_steps
* access_steps,
track_length);
}
return EXIT_SUCCESS;
return std::visit(
[&](auto& bField) -> int {
using field_type =
typename std::decay_t<decltype(bField)>::element_type;
if constexpr (
!std::is_same_v<
field_type,
InterpolatedBFieldMap2D> && !std::is_same_v<field_type, InterpolatedBFieldMap3D>) {
std::cout << "Bfield map could not be read. Exiting." << std::endl;
return EXIT_FAILURE;
} else {
// Step-wise access pattern
accessStepWise(*bField,
magFieldContext,
nEvents,
theta_steps,
thetar[0],
theta_step,
phi_steps,
phir[0],
phi_step,
access_steps,
access_step);
// Random access pattern
accessRandom(*bField,
magFieldContext,
nEvents * theta_steps * phi_steps * access_steps,
track_length);
return EXIT_SUCCESS;
}
},
bFieldVar);
}
......@@ -13,10 +13,16 @@
#include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/BField/BFieldOptions.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "BFieldWritingBase.hpp"
namespace po = boost::program_options;
template <class T>
struct always_false : std::false_type
{
};
/// The main executable
///
/// Creates an InterpolatedBFieldMap from a txt or csv file and writes out the
......@@ -71,25 +77,22 @@ main(int argc, char* argv[])
auto vm = FW::Options::parse(desc, argc, argv);
if (vm.empty()) { return EXIT_FAILURE; }
auto bField = FW::Options::readBField(vm);
auto field2D = std::get<std::shared_ptr<InterpolatedBFieldMap2D>>(bField);
auto field3D = std::get<std::shared_ptr<InterpolatedBFieldMap3D>>(bField);
if (!field2D && !field3D) {
std::cout << "Bfield map could not be read. Exiting." << std::endl;
return EXIT_FAILURE;
}
// write it out
if (field2D) {
// the 2-dimensional field case
FW::BField::writeField<po::variables_map, InterpolatedBFieldMap2D>(vm,
field2D);
} else {
// the 3-dimensional field case
FW::BField::writeField<po::variables_map, InterpolatedBFieldMap3D>(vm,
field3D);
}
auto bFieldVar = FW::Options::readBField(vm);
return EXIT_SUCCESS;
return std::visit(
[&](auto& bField) -> int {
using field_type =
typename std::decay_t<decltype(bField)>::element_type;
if constexpr (
!std::is_same_v<
field_type,
InterpolatedBFieldMap2D> && !std::is_same_v<field_type, InterpolatedBFieldMap3D>) {
std::cout << "Bfield map could not be read. Exiting." << std::endl;
return EXIT_FAILURE;
} else {
FW::BField::writeField<field_type>(vm, bField);
return EXIT_SUCCESS;
}
},
bFieldVar);
}
......@@ -11,12 +11,15 @@
#include "ACTFW/Plugins/Root/RootBFieldWriter.hpp"
#include "ACTFW/Utilities/Options.hpp"
#include <boost/program_options.hpp>
namespace FW {
namespace BField {
template <typename vmap_t, typename bfield_t>
template <typename bfield_t>
void
writeField(vmap_t vm, std::shared_ptr<const bfield_t> bField)
writeField(boost::program_options::variables_map vm,
std::shared_ptr<const bfield_t> bField)
{
// Write the interpolated magnetic field
typename FW::Root::RootBFieldWriter<bfield_t>::Config writerConfig;
......
add_library(
ACTFWExamplesCommon SHARED
src/CommonGeometry.cpp
src/CommonOptions.cpp
src/GeometryExampleBase.cpp
src/MaterialMappingBase.cpp
src/MaterialValidationBase.cpp
src/PropagationExampleBase.cpp)
set(src_files
src/CommonGeometry.cpp
src/CommonOptions.cpp
src/GeometryExampleBase.cpp
src/MaterialMappingBase.cpp
src/MaterialValidationBase.cpp
src/PropagationExampleBase.cpp )
# append Fatras example is Pythia8 is avaialbe
if(USE_PYTHIA8)
list(APPEND src_files
src/FatrasExampleBase.cpp
src/FatrasDigitizationBase.cpp
src/FatrasSimulationBase.cpp
src/FatrasEvgenBase.cpp
src/FittingBase.cpp)
endif()
add_library(ACTFWExamplesCommon SHARED ${src_files})
target_include_directories(
ACTFWExamplesCommon
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
......@@ -13,7 +24,7 @@ target_link_libraries(
ACTFWExamplesCommon
PUBLIC ActsCore FatrasCore ACTFramework ACTFWObjPlugin ACTFWCsvPlugin
ACTFWJsonPlugin ACTFWRootPlugin ACTFWDetectorsCommon ACTFWBFieldPlugin
ACTFWDigitization ACTFWFatras ActsFrameworkGenerators ACTFWMaterialMapping
ACTFWDigitization ACTFWPropagation ACTFWFatras ActsFrameworkGenerators ACTFWMaterialMapping
ACTFWFitting)
if(USE_PYTHIA8)
......
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "detail/FatrasDigitizationBase.hpp"
#include "ACTFW/Digitization/DigitizationAlgorithm.hpp"
#include "ACTFW/Digitization/DigitizationOptions.hpp"
#include "ACTFW/EventData/Barcode.hpp"
#include "ACTFW/Framework/RandomNumbers.hpp"
#include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/Csv/CsvPlanarClusterWriter.hpp"
#include "ACTFW/Plugins/Obj/ObjSpacePointWriter.hpp"
#include "ACTFW/Plugins/Root/RootPlanarClusterWriter.hpp"
#include "ACTFW/Utilities/OptionsFwd.hpp"
#include "Acts/Plugins/Digitization/PlanarModuleStepper.hpp"
void
setupDigitization(boost::program_options::variables_map& vm,
FW::Sequencer& sequencer,
std::shared_ptr<FW::BarcodeSvc> barcodeSvc,
std::shared_ptr<FW::RandomNumbers> randomNumberSvc)
{
// Read the standard options
auto logLevel = FW::Options::readLogLevel(vm);
// Set the module stepper
auto pmStepper = std::make_shared<Acts::PlanarModuleStepper>(
Acts::getDefaultLogger("PlanarModuleStepper", logLevel));
// Read the digitization configuration
auto digiConfig = FW::Options::readDigitizationConfig(vm);
// Set the random number service
digiConfig.randomNumberSvc = randomNumberSvc;
digiConfig.planarModuleStepper = pmStepper;
// set te hit collection
digiConfig.simulatedHitCollection
= vm["fatras-sim-hits"].template as<std::string>();
// Create the algorithm and add it to the sequencer
sequencer.addAlgorithm(
std::make_shared<FW::DigitizationAlgorithm>(digiConfig, logLevel));
// Output directory
std::string outputDir = vm["output-dir"].template as<std::string>();
// Write digitisation output as Csv files
if (vm["output-csv"].template as<bool>()) {
// clusters as root
FW::Csv::CsvPlanarClusterWriter::Config clusterWriterCsvConfig;
clusterWriterCsvConfig.inputClusters = digiConfig.clusterCollection;
clusterWriterCsvConfig.outputDir = outputDir;
auto clusteWriterCsv = std::make_shared<FW::Csv::CsvPlanarClusterWriter>(
clusterWriterCsvConfig);
// Add to the sequencer
sequencer.addWriter(clusteWriterCsv);
}
// Write digitsation output as ROOT files
if (vm["output-root"].template as<bool>()) {
// clusters as root
FW::Root::RootPlanarClusterWriter::Config clusterWriterRootConfig;
clusterWriterRootConfig.collection = digiConfig.clusterCollection;
clusterWriterRootConfig.filePath
= FW::joinPaths(outputDir, digiConfig.clusterCollection + ".root");
clusterWriterRootConfig.treeName = digiConfig.clusterCollection;
auto clusteWriterRoot = std::make_shared<FW::Root::RootPlanarClusterWriter>(
clusterWriterRootConfig);
// Add to the sequencer
sequencer.addWriter(clusteWriterRoot);
}
}
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "detail/FatrasEvgenBase.hpp"
#include "ACTFW/EventData/Barcode.hpp"
#include "ACTFW/Framework/RandomNumbers.hpp"
#include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Generators/EventGenerator.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Options/ParticleGunOptions.hpp"
#include "ACTFW/Options/Pythia8Options.hpp"
#include "ACTFW/Plugins/Csv/CsvParticleWriter.hpp"
#include "ACTFW/Plugins/Root/RootParticleWriter.hpp"
#include "ACTFW/Utilities/Paths.hpp"
void
setupEvgenInput(boost::program_options::variables_map& vm,
FW::Sequencer& sequencer,
std::shared_ptr<FW::BarcodeSvc> barcodeSvc,
std::shared_ptr<FW::RandomNumbers> randomNumberSvc)
{
// Read the standard options
auto logLevel = FW::Options::readLogLevel(vm);
// Add requested event generator
auto evgenInput = vm["evg-input-type"].template as<std::string>();
if (evgenInput == "gun") {
auto evgCfg = FW::Options::readParticleGunOptions(vm);
evgCfg.output = "particles";
evgCfg.randomNumbers = randomNumberSvc;
evgCfg.barcodeSvc = barcodeSvc;
sequencer.addReader(std::make_shared<FW::EventGenerator>(evgCfg, logLevel));
} else if (evgenInput == "pythia8") {
auto evgCfg = FW::Options::readPythia8Options(vm);
evgCfg.output = "particles";
evgCfg.randomNumbers = randomNumberSvc;
evgCfg.barcodeSvc = barcodeSvc;
sequencer.addReader(std::make_shared<FW::EventGenerator>(evgCfg, logLevel));
} else {
throw std::runtime_error("unknown event generator input: " + evgenInput);
}
// Output directory
std::string outputDir = vm["output-dir"].template as<std::string>();
// Write particles as CSV files
if (vm["output-csv"].template as<bool>()) {
FW::Csv::CsvParticleWriter::Config pWriterCsvConfig;
pWriterCsvConfig.inputEvent = "particles";
pWriterCsvConfig.outputDir = outputDir;
pWriterCsvConfig.outputStem = "particles";
sequencer.addWriter(
std::make_shared<FW::Csv::CsvParticleWriter>(pWriterCsvConfig));
}
// Write particles as ROOT file
if (vm["output-root"].template as<bool>()) {
// Write particles as ROOT TTree
FW::Root::RootParticleWriter::Config pWriterRootConfig;
pWriterRootConfig.collection = "particles";
pWriterRootConfig.filePath = FW::joinPaths(outputDir, "particles.root");
pWriterRootConfig.treeName = "particles";
pWriterRootConfig.barcodeSvc = barcodeSvc;
sequencer.addWriter(
std::make_shared<FW::Root::RootParticleWriter>(pWriterRootConfig));
}
}
......@@ -20,6 +20,7 @@
#include "ACTFW/Geometry/CommonGeometry.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Options/ParticleGunOptions.hpp"
#include "ACTFW/Options/Pythia8Options.hpp"
#include "ACTFW/Plugins/BField/BFieldOptions.hpp"
#include "ACTFW/Plugins/Csv/CsvParticleWriter.hpp"
......@@ -86,8 +87,7 @@ fatrasExample(int argc, char* argv[], FW::IBaseDetector& detector)
setupDigitization(vm, sequencer, barcodeSvc, randomNumberSvc);
// (D) TRUTH TRACKING
setupFitting<po::variables_map>(
vm, sequencer, tGeometry, barcodeSvc, randomNumberSvc);
setupFitting(vm, sequencer, tGeometry, barcodeSvc, randomNumberSvc);
// (E) PATTERN RECOGNITION
......
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "detail/FatrasSimulationBase.hpp"
#include "ACTFW/EventData/Barcode.hpp"
#include "ACTFW/EventData/SimHit.hpp"
#include "ACTFW/EventData/SimParticle.hpp"
#include "ACTFW/EventData/SimVertex.hpp"
#include "ACTFW/Fatras/FatrasAlgorithm.hpp"
#include "ACTFW/Fatras/FatrasOptions.hpp"
#include "ACTFW/Framework/RandomNumbers.hpp"
#include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/BField/BFieldOptions.hpp"
#include "ACTFW/Plugins/BField/ScalableBField.hpp"
#include "ACTFW/Plugins/Csv/CsvParticleWriter.hpp"
#include "ACTFW/Plugins/Root/RootParticleWriter.hpp"
#include "ACTFW/Plugins/Root/RootSimHitWriter.hpp"
#include "ACTFW/Utilities/Paths.hpp"
#include "Acts/Geometry/GeometryID.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/MagneticField/ConstantBField.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/MagneticField/SharedBField.hpp"
#include "Acts/Propagator/EigenStepper.hpp"
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Propagator/StraightLineStepper.hpp"
#include "Acts/Propagator/detail/DebugOutputActor.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Fatras/Kernel/Interactor.hpp"
#include "Fatras/Kernel/SelectorList.hpp"
#include "Fatras/Kernel/Simulator.hpp"
#include "Fatras/Selectors/ChargeSelectors.hpp"
#include "Fatras/Selectors/KinematicCasts.hpp"
#include "Fatras/Selectors/SelectorHelpers.hpp"
typedef FW::Data::SimHit FatrasHit;
typedef std::vector<FW::Data::SimVertex> FatrasEvent;
namespace po = boost::program_options;
/// Construct SimHits from Fatras.
struct SimHitCreator
{
/// @param surface is the Surface where the hit is created
/// @param position is the global hit position
/// @param direction is the momentum direction at hit position
/// @param value is the simulated value
/// @param time is the timeStamp
/// @param particle is the particle for the truth link
FW::Data::SimHit
operator()(const Acts::Surface& surface,
const Acts::Vector3D& position,
const Acts::Vector3D& direction,
double value,
double time,
const FW::Data::SimParticle& simParticle) const
{
FW::Data::SimHit simHit(surface);
simHit.position = position;
simHit.time = time;
simHit.direction = direction;
simHit.value = value;
simHit.particle = simParticle;
return simHit;
}
};
/// Simple struct to select sensitive surfaces
struct SurfaceSelector
{
bool selectSensitive = true;
bool selectMaterial = false;
bool selectPassive = false;
/// SurfaceSelector with options
///
/// @param sSensitive is the directive to select sensitive surfaces
/// @param sMaterial is the directive to select material surfaces
/// @param sPassive is the directive to select passive surfaces
SurfaceSelector(bool sSensitive = true,
bool sMaterial = false,
bool sPassive = false)
: selectSensitive(sSensitive)
, selectMaterial(sMaterial)
, selectPassive(sPassive)
{
}
/// Call operator to check if a surface should be selected
///
/// @param surface is the test surface
bool
operator()(const Acts::Surface& surface) const
{
if (selectSensitive && surface.associatedDetectorElement()) { return true; }
if (selectMaterial && surface.surfaceMaterial()) { return true; }
if (selectPassive) { return true; }
return false;
}
};
/// @brief Simulation setup for the FatrasAlgorithm
///
/// @tparam bfield_t Type of the bfield for the simulation to be set up
///
/// @param fieldMap The field map for the simulation setup
/// @param sequencer The framework sequencer
/// @param vm The boost variable map to resolve
/// @param tGeometry The TrackingGeometry for the tracking setup
/// @param barcodesSvc The barcode service to be used for the simulation
/// @param randomNumberSvc The random number service to be used for the
/// simulation
template <typename bfield_t>
void
setupSimulationAlgorithm(
bfield_t fieldMap,
FW::Sequencer& sequencer,
po::variables_map& vm,
std::shared_ptr<const Acts::TrackingGeometry> tGeometry,
std::shared_ptr<FW::BarcodeSvc> barcodeSvc,
std::shared_ptr<FW::RandomNumbers> randomNumberSvc)
{
// Read the log level
Acts::Logging::Level logLevel = FW::Options::readLogLevel(vm);
/// Read the evgen particle collection
std::string evgenCollection = "particles";
// Create a navigator for this tracking geometry
Acts::Navigator cNavigator(tGeometry);
Acts::Navigator nNavigator(tGeometry);
// using ChargedStepper = Acts::AtlasStepper<bfield_t>;
using ChargedStepper = Acts::EigenStepper<bfield_t>;
using ChargedPropagator = Acts::Propagator<ChargedStepper, Acts::Navigator>;
using NeutralStepper = Acts::StraightLineStepper;
using NeutralPropagator = Acts::Propagator<NeutralStepper, Acts::Navigator>;
ChargedStepper cStepper(std::move(fieldMap));
ChargedPropagator cPropagator(std::move(cStepper), std::move(cNavigator));
NeutralStepper nStepper;
NeutralPropagator nPropagator(std::move(nStepper), std::move(nNavigator));
// The Selector for charged particles, including kinematic cuts
typedef Fatras::ChargedSelector CSelector;
typedef Fatras::Max<Fatras::casts::absEta> CMaxEtaAbs;
typedef Fatras::Min<Fatras::casts::pT> CMinPt;
typedef Fatras::SelectorListAND<CSelector, CMinPt, CMaxEtaAbs>
ChargedSelector;
typedef Fatras::NeutralSelector NSelector;
typedef Fatras::Max<Fatras::casts::absEta> NMaxEtaAbs;
typedef Fatras::Min<Fatras::casts::E> NMinE;
typedef Fatras::SelectorListAND<NSelector, NMinE, NMaxEtaAbs> NeutralSelector;
typedef Fatras::PhysicsList<> PhysicsList;
typedef Fatras::Interactor<FW::RandomEngine,
FW::Data::SimParticle,
FW::Data::SimHit,
SimHitCreator,
SurfaceSelector,
PhysicsList>
ChargedInteractor;
typedef Fatras::Interactor<FW::RandomEngine,
FW::Data::SimParticle,
FW::Data::SimHit,
SimHitCreator>
NeutralInteractor;
typedef Fatras::Simulator<ChargedPropagator,
ChargedSelector,
ChargedInteractor,
NeutralPropagator,
NeutralSelector,
NeutralInteractor>
FatrasSimulator;
FatrasSimulator fatrasSimulator(cPropagator, nPropagator);
fatrasSimulator.debug = vm["fatras-debug-output"].template as<bool>();
using FatrasAlgorithm = FW::FatrasAlgorithm<FatrasSimulator, FatrasEvent>;
typename FatrasAlgorithm::Config fatrasConfig
= FW::Options::readFatrasConfig<po::variables_map,
FatrasSimulator,
FatrasEvent>(vm, fatrasSimulator);
fatrasConfig.randomNumberSvc = randomNumberSvc;
fatrasConfig.inputEventCollection = evgenCollection;
// Finally the fatras algorithm
sequencer.addAlgorithm(
std::make_shared<FatrasAlgorithm>(fatrasConfig, logLevel));
// Output directory
std::string outputDir = vm["output-dir"].template as<std::string>();
// Write simulation information as CSV files
std::shared_ptr<FW::Csv::CsvParticleWriter> pWriterCsv = nullptr;
if (vm["output-csv"].template as<bool>()) {
FW::Csv::CsvParticleWriter::Config pWriterCsvConfig;
pWriterCsvConfig.inputEvent = fatrasConfig.simulatedEventCollection;
pWriterCsvConfig.outputDir = outputDir;
pWriterCsvConfig.outputStem = fatrasConfig.simulatedEventCollection;
sequencer.addWriter(
std::make_shared<FW::Csv::CsvParticleWriter>(pWriterCsvConfig));
}
// Write simulation information as ROOT files
std::shared_ptr<FW::Root::RootParticleWriter> pWriterRoot = nullptr;
if (vm["output-root"].template as<bool>()) {
// Write particles as ROOT TTree
FW::Root::RootParticleWriter::Config pWriterRootConfig;
pWriterRootConfig.collection = fatrasConfig.simulatedEventCollection;
pWriterRootConfig.filePath = FW::joinPaths(
outputDir, fatrasConfig.simulatedEventCollection + ".root");
pWriterRootConfig.treeName = fatrasConfig.simulatedEventCollection;
pWriterRootConfig.barcodeSvc = barcodeSvc;
sequencer.addWriter(
std::make_shared<FW::Root::RootParticleWriter>(pWriterRootConfig));
// Write simulated hits as ROOT TTree
FW::Root::RootSimHitWriter::Config fhitWriterRootConfig;
fhitWriterRootConfig.collection = fatrasConfig.simulatedHitCollection;
fhitWriterRootConfig.filePath = FW::joinPaths(
outputDir, fatrasConfig.simulatedHitCollection + ".root");
fhitWriterRootConfig.treeName = fatrasConfig.simulatedHitCollection;
sequencer.addWriter(
std::make_shared<FW::Root::RootSimHitWriter>(fhitWriterRootConfig));
}
}
void
setupSimulation(boost::program_options::variables_map& vm,
FW::Sequencer& sequencer,
std::shared_ptr<const Acts::TrackingGeometry> tGeometry,
std::shared_ptr<FW::BarcodeSvc> barcodeSvc,
std::shared_ptr<FW::RandomNumbers> randomNumberSvc)
{
// Create BField service
auto bFieldVar = FW::Options::readBField(vm);
std::visit(
[&](auto& bField) {
using field_type =
typename std::decay_t<decltype(bField)>::element_type;
Acts::SharedBField<field_type> fieldMap(bField);
setupSimulationAlgorithm(std::move(fieldMap),
sequencer,
vm,
tGeometry,
barcodeSvc,
randomNumberSvc);
},
bFieldVar);
}
// This file is part of the Acts project.
//
// Copyright (C) 2019 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "detail/FittingBase.hpp"
#include "ACTFW/EventData/Barcode.hpp"
#include "ACTFW/Fitting/FittingAlgorithm.hpp"
#include "ACTFW/Fitting/FittingOptions.hpp"
#include "ACTFW/Framework/Sequencer.hpp"
#include "ACTFW/Options/CommonOptions.hpp"
#include "ACTFW/Plugins/BField/BFieldOptions.hpp"
#include "ACTFW/Plugins/BField/ScalableBField.hpp"
#include "ACTFW/Plugins/Root/RootPerformanceWriter.hpp"
#include "ACTFW/Plugins/Root/RootTrajectoryWriter.hpp"
#include "ACTFW/Utilities/Paths.hpp"
#include "Acts/Fitter/GainMatrixSmoother.hpp"
#include "Acts/Fitter/GainMatrixUpdater.hpp"
#include "Acts/Fitter/KalmanFitter.hpp"
#include "Acts/Geometry/GeometryID.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/MagneticField/ConstantBField.hpp"
#include "Acts/MagneticField/InterpolatedBFieldMap.hpp"
#include "Acts/MagneticField/SharedBField.hpp"
#include "Acts/Propagator/EigenStepper.hpp"
#include "Acts/Propagator/Navigator.hpp"
#include "Acts/Propagator/Propagator.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include <boost/program_options.hpp>
namespace po = boost::program_options;
void
setupFitting(boost::program_options::variables_map& vm,
FW::Sequencer& sequencer,
std::shared_ptr<const Acts::TrackingGeometry> tGeometry,
std::shared_ptr<FW::BarcodeSvc> barcodeSvc,
std::shared_ptr<FW::RandomNumbers> randomNumberSvc)
{
using Updater = Acts::GainMatrixUpdater<Acts::BoundParameters>;
using Smoother = Acts::GainMatrixSmoother<Acts::BoundParameters>;
// Read the log level
Acts::Logging::Level logLevel = FW::Options::readLogLevel(vm);
// Create a navigator for this tracking geometry
Acts::Navigator cNavigator(tGeometry);
cNavigator.resolvePassive = false;
cNavigator.resolveMaterial = true;
cNavigator.resolveSensitive = true;
FW::FittingAlgorithm::Config fittingConfig;
FW::Options::readFittingConfig(vm, fittingConfig);
fittingConfig.randomNumberSvc = randomNumberSvc;
// create BField service
auto bFieldVar = FW::Options::readBField(vm);
std::visit(
[&](auto& bField) {
using field_type =
typename std::decay_t<decltype(bField)>::element_type;
Acts::SharedBField<field_type> fieldMap(bField);
using ChargedStepper = Acts::EigenStepper<decltype(fieldMap)>;
using ChargedPropagator
= Acts::Propagator<ChargedStepper, Acts::Navigator>;
ChargedStepper cStepper(std::move(fieldMap));
ChargedPropagator cPropagator(std::move(cStepper),
std::move(cNavigator));
using KalmanFitter
= Acts::KalmanFitter<ChargedPropagator, Updater, Smoother>;
auto kFitter = std::make_shared<KalmanFitter>(
cPropagator, Acts::getDefaultLogger("KalmanFilter", logLevel));
fittingConfig.fitFunction
= [kFitter](
std::vector<FW::FittingAlgorithm::Identifier>& sourceLinks,
const FW::FittingAlgorithm::StartParameters& sParameters,
const Acts::KalmanFitterOptions& kfOptions)
-> FW::FittingAlgorithm::ResultType {
return kFitter->fit(sourceLinks, sParameters, kfOptions);
};
},
bFieldVar);
std::string trackCollection = fittingConfig.trackCollection;
std::string simulatedEventCollection = fittingConfig.simulatedEventCollection;
// Finally the fitting algorithm
sequencer.addAlgorithm(std::make_shared<FW::FittingAlgorithm>(
std::move(fittingConfig), logLevel));
// Output directory
std::string outputDir = vm["output-dir"].template as<std::string>();
// Write fitted tracks as ROOT files
if (vm["output-root"].template as<bool>()) {
FW::Root::RootTrajectoryWriter::Config tWriterRootConfig;
tWriterRootConfig.trackCollection = trackCollection;
tWriterRootConfig.simulatedEventCollection = simulatedEventCollection;
tWriterRootConfig.filePath
= FW::joinPaths(outputDir, trackCollection + ".root");
tWriterRootConfig.treeName = trackCollection;
sequencer.addWriter(
std::make_shared<FW::Root::RootTrajectoryWriter>(tWriterRootConfig));
}
// Write performance plots as ROOT files
if (vm["output-root"].template as<bool>()) {
FW::ResPlotTool::Config resPlotToolConfig;
FW::Root::RootPerformanceWriter::Config perfValidationConfig;
perfValidationConfig.resPlotToolConfig = resPlotToolConfig;
perfValidationConfig.trackCollection = trackCollection;
perfValidationConfig.simulatedEventCollection = simulatedEventCollection;
perfValidationConfig.filePath
= FW::joinPaths(outputDir, trackCollection + "_performance.root");
sequencer.addWriter(std::make_shared<FW::Root::RootPerformanceWriter>(
perfValidationConfig));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment