-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #480 from beomki-yeo/res-plots
Resolution plot updates with truth fitting examples
- Loading branch information
Showing
24 changed files
with
940 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
examples/options/include/traccc/options/telescope_detector_options.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Project include(s). | ||
#include "traccc/options/options.hpp" | ||
|
||
// Detray include(s). | ||
#include "detray/definitions/units.hpp" | ||
|
||
// Boost | ||
#include <boost/program_options.hpp> | ||
|
||
namespace traccc { | ||
|
||
namespace po = boost::program_options; | ||
|
||
template <typename scalar_t> | ||
struct telescope_detector_options { | ||
bool empty_material; | ||
unsigned int n_planes; | ||
scalar_t thickness; | ||
scalar_t spacing; | ||
scalar_t smearing; | ||
scalar_t half_length; | ||
|
||
telescope_detector_options(po::options_description& desc) { | ||
desc.add_options()("empty_material", | ||
po::value<bool>()->default_value(false), | ||
"Build detector without materials"); | ||
desc.add_options()("n_planes", | ||
po::value<unsigned int>()->default_value(9), | ||
"Number of planes"); | ||
desc.add_options()("thickness", | ||
po::value<scalar_t>()->default_value(0.5f), | ||
"Slab thickness in [mm]"); | ||
desc.add_options()("spacing", | ||
po::value<scalar_t>()->default_value(20.f), | ||
"Space between planes in [mm]"); | ||
desc.add_options()("smearing", | ||
po::value<scalar_t>()->default_value(50.f), | ||
"Measurement smearing in [um]"); | ||
desc.add_options()("half_length", | ||
po::value<scalar_t>()->default_value(1000000.f), | ||
"Half length of plane [mm]"); | ||
} | ||
|
||
void read(const po::variables_map& vm) { | ||
empty_material = vm["empty_material"].as<bool>(); | ||
n_planes = vm["n_planes"].as<unsigned int>(); | ||
thickness = vm["thickness"].as<scalar_t>() * detray::unit<scalar_t>::mm; | ||
spacing = vm["spacing"].as<scalar_t>() * detray::unit<scalar_t>::mm; | ||
smearing = vm["smearing"].as<scalar_t>() * detray::unit<scalar_t>::um; | ||
half_length = | ||
vm["half_length"].as<scalar_t>() * detray::unit<scalar_t>::mm; | ||
} | ||
}; | ||
|
||
} // namespace traccc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Project include(s). | ||
#include "traccc/definitions/common.hpp" | ||
#include "traccc/definitions/primitives.hpp" | ||
#include "traccc/fitting/fitting_algorithm.hpp" | ||
#include "traccc/fitting/kalman_filter/kalman_fitter.hpp" | ||
#include "traccc/io/read_geometry.hpp" | ||
#include "traccc/io/read_measurements.hpp" | ||
#include "traccc/io/utils.hpp" | ||
#include "traccc/options/common_options.hpp" | ||
#include "traccc/options/handle_argument_errors.hpp" | ||
#include "traccc/options/propagation_options.hpp" | ||
#include "traccc/resolution/fitting_performance_writer.hpp" | ||
#include "traccc/utils/seed_generator.hpp" | ||
|
||
// Detray include(s). | ||
#include "detray/core/detector.hpp" | ||
#include "detray/core/detector_metadata.hpp" | ||
#include "detray/detectors/bfield.hpp" | ||
#include "detray/io/common/detector_reader.hpp" | ||
#include "detray/propagator/navigator.hpp" | ||
#include "detray/propagator/propagator.hpp" | ||
#include "detray/propagator/rk_stepper.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/memory/host_memory_resource.hpp> | ||
|
||
// System include(s). | ||
#include <exception> | ||
#include <iomanip> | ||
#include <iostream> | ||
|
||
using namespace traccc; | ||
namespace po = boost::program_options; | ||
|
||
// The main routine | ||
// | ||
int main(int argc, char* argv[]) { | ||
// Set up the program options | ||
po::options_description desc("Allowed options"); | ||
|
||
// Add options | ||
desc.add_options()("help,h", "Give some help with the program's options"); | ||
traccc::common_options common_opts(desc); | ||
traccc::propagation_options<scalar> propagation_opts(desc); | ||
|
||
po::variables_map vm; | ||
po::store(po::parse_command_line(argc, argv, desc), vm); | ||
|
||
// Check errors | ||
traccc::handle_argument_errors(vm, desc); | ||
|
||
// Read options | ||
common_opts.read(vm); | ||
propagation_opts.read(vm); | ||
|
||
std::cout << "Running " << argv[0] << " " << common_opts.input_directory | ||
<< " " << common_opts.events << std::endl; | ||
|
||
/// Type declarations | ||
using host_detector_type = detray::detector<detray::default_metadata, | ||
detray::host_container_types>; | ||
|
||
using b_field_t = covfie::field<detray::bfield::const_bknd_t>; | ||
using rk_stepper_type = | ||
detray::rk_stepper<b_field_t::view_t, traccc::transform3, | ||
detray::constrained_step<>>; | ||
|
||
using host_navigator_type = detray::navigator<const host_detector_type>; | ||
using host_fitter_type = | ||
traccc::kalman_fitter<rk_stepper_type, host_navigator_type>; | ||
|
||
// Memory resources used by the application. | ||
vecmem::host_memory_resource host_mr; | ||
|
||
// Performance writer | ||
traccc::fitting_performance_writer fit_performance_writer( | ||
traccc::fitting_performance_writer::config{}); | ||
|
||
/***************************** | ||
* Build a geometry | ||
*****************************/ | ||
|
||
// B field value and its type | ||
// @TODO: Set B field as argument | ||
const traccc::vector3 B{0, 0, 2 * detray::unit<traccc::scalar>::T}; | ||
auto field = detray::bfield::create_const_field(B); | ||
|
||
// Read the detector | ||
detray::io::detector_reader_config reader_cfg{}; | ||
reader_cfg | ||
.add_file(traccc::io::data_directory() + common_opts.detector_file) | ||
.add_file(traccc::io::data_directory() + common_opts.material_file) | ||
.add_file(traccc::io::data_directory() + common_opts.grid_file); | ||
|
||
const auto [host_det, names] = | ||
detray::io::read_detector<host_detector_type>(host_mr, reader_cfg); | ||
|
||
/***************************** | ||
* Do the reconstruction | ||
*****************************/ | ||
|
||
/// Standard deviations for seed track parameters | ||
static constexpr std::array<scalar, e_bound_size> stddevs = { | ||
0.03 * detray::unit<scalar>::mm, | ||
0.03 * detray::unit<scalar>::mm, | ||
0.017, | ||
0.017, | ||
0.01 / detray::unit<scalar>::GeV, | ||
1 * detray::unit<scalar>::ns}; | ||
|
||
// Fitting algorithm object | ||
typename traccc::fitting_algorithm<host_fitter_type>::config_type fit_cfg; | ||
fit_cfg.step_constraint = propagation_opts.step_constraint; | ||
traccc::fitting_algorithm<host_fitter_type> host_fitting(fit_cfg); | ||
|
||
// Seed generator | ||
traccc::seed_generator<host_detector_type> sg(host_det, stddevs); | ||
|
||
// Iterate over events | ||
for (unsigned int event = common_opts.skip; | ||
event < common_opts.events + common_opts.skip; ++event) { | ||
|
||
// Truth Track Candidates | ||
traccc::event_map2 evt_map2(event, common_opts.input_directory, | ||
common_opts.input_directory, | ||
common_opts.input_directory); | ||
|
||
traccc::track_candidate_container_types::host truth_track_candidates = | ||
evt_map2.generate_truth_candidates(sg, host_mr); | ||
|
||
// Run fitting | ||
auto track_states = | ||
host_fitting(host_det, field, truth_track_candidates); | ||
|
||
std::cout << "Number of fitted tracks: " << track_states.size() | ||
<< std::endl; | ||
|
||
const unsigned int n_fitted_tracks = track_states.size(); | ||
|
||
if (common_opts.check_performance) { | ||
|
||
for (unsigned int i = 0; i < n_fitted_tracks; i++) { | ||
const auto& trk_states_per_track = track_states.at(i).items; | ||
|
||
const auto& fit_info = track_states[i].header; | ||
|
||
fit_performance_writer.write(trk_states_per_track, fit_info, | ||
host_det, evt_map2); | ||
} | ||
} | ||
} | ||
|
||
if (common_opts.check_performance) { | ||
fit_performance_writer.finalize(); | ||
} | ||
|
||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.