ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::detector_scanner Namespace Reference

Run a scan on detector object by shooting test particles through it. More...

Functions

template<dindex invalid_value = dindex_invalid, typename entry_type = std::pair<dindex, dindex>>
auto build_adjacency (const std::vector< std::pair< entry_type, entry_type > > &portal_trace, const std::vector< entry_type > &module_trace, dvector< dindex > &adj_matrix, std::unordered_set< dindex > &obj_hashes)
 Build an adjacency list from intersection traces.
template<dindex invalid_value = dindex_invalid, typename entry_type = std::pair<dindex, dindex>>
auto build_adjacency (const std::vector< std::pair< entry_type, entry_type > > &portal_trace, const std::vector< entry_type > &module_trace, std::map< dindex, std::map< dindex, dindex > > &adj_list, std::unordered_set< dindex > &obj_hashes)
 Build an adjacency list from intersection traces.
template<dindex invalid_value = dindex_invalid, bool check_sorted_trace = true, typename entry_type = std::pair<dindex, dindex>>
bool check_connectivity (std::vector< std::pair< entry_type, entry_type > > trace, dindex start_volume=0u)
 Check if a set of volume indices from portal intersections from a path (works even if the pairs are not sorted).
template<concepts::detector detector_t>
bool check_trace (const dvector< intersection_record< detector_t > > &intersection_trace, const dindex start_index, dvector< dindex > &adj_mat_scan, std::unordered_set< dindex > &obj_hashes)
 Run all checks on an intersection trace.
template<concepts::detector detector_t, typename trajectory_t>
void display_error (const typename detector_t::geometry_context gctx, const detector_t &det, const typename detector_t::name_map &vol_names, const std::string &test_name, const trajectory_t &test_track, const dvector< intersection_record< detector_t > > &truth_trace, const detray::svgtools::styling::style &svg_style, const std::size_t i_track, const std::size_t n_tracks, const dvector< intersection_record< detector_t > > &recorded_trace={}, const dindex_range overlap_idx={detray::detail::invalid_value< dindex >(), detray::detail::invalid_value< dindex >()}, const bool verbose=true)
 Print the failed intersection trace as svg (dumped to files).
template<concepts::detector detector_t>
dindex_range overlaps_removal (dvector< intersection_record< detector_t > > &intersection_records, const float tol=1e-4f *unit< float >::mm)
 Filter the intersection trace for overlapping surfaces and remove duplicates.
std::string print_adj (const dvector< dindex > &adjacency_matrix)
 Print an adjacency list.
template<concepts::detector detector_t>
std::string print_trace (const dvector< intersection_record< detector_t > > &truth_trace, std::size_t n)
 Print an intersection trace.
template<concepts::detector detector_t, typename allocator_t>
auto read (const std::string &intersection_file_name, const std::string &track_param_file_name, std::vector< std::vector< intersection_record< detector_t >, allocator_t > > &intersection_traces)
 Read the intersection_record from file.
template<template< typename > class scan_type, concepts::detector detector_t, typename trajectory_t, typename... Args>
auto run (const typename detector_t::geometry_context gctx, const detector_t &detector, const trajectory_t &traj, Args &&...args)
 Run a scan on detector object by shooting test particles through it.
template<concepts::detector detector_t>
auto trace_intersections (const dvector< intersection_record< detector_t > > &intersection_records, dindex start_volume=0u)
 Check if a recording of portal/module intersections form a coherent trace through a geometry.
template<concepts::detector detector_t, typename allocator_t>
auto write_intersections (const std::string &intersection_file_name, const std::vector< dvector< intersection_record< detector_t > >, allocator_t > &intersection_traces)
 Write the intersection_traces to file.
template<concepts::detector detector_t, typename allocator_t>
auto write_tracks (const std::string &track_param_file_name, const std::vector< dvector< intersection_record< detector_t > >, allocator_t > &intersection_traces)
 Write the intersection_traces to file.

Detailed Description

Run a scan on detector object by shooting test particles through it.

Function Documentation

◆ build_adjacency() [1/2]

template<dindex invalid_value = dindex_invalid, typename entry_type = std::pair<dindex, dindex>>
auto detray::detector_scanner::build_adjacency ( const std::vector< std::pair< entry_type, entry_type > > & portal_trace,
const std::vector< entry_type > & module_trace,
dvector< dindex > & adj_matrix,
std::unordered_set< dindex > & obj_hashes )

Build an adjacency list from intersection traces.

Template Parameters
invalid_valueto keep the implementation simple, all indices are of type dindex here, but that does not need to be the case in the intersection code, so we need to know what the invalid value is interpreted as a dindex
entry_typethe record entry, which must contain the portal index and the volume index the portal was discovered in.
Parameters
portal_tracethe portal indices and their volume links (in adjacent portal pairs)
module_tracethe module indices and their volume links
adj_matrixadjacency matrix to populate
obj_hashesrecord which modules/portals were already added
Returns
an adjacency list from the traced ray scan of a given geometry.

◆ build_adjacency() [2/2]

template<dindex invalid_value = dindex_invalid, typename entry_type = std::pair<dindex, dindex>>
auto detray::detector_scanner::build_adjacency ( const std::vector< std::pair< entry_type, entry_type > > & portal_trace,
const std::vector< entry_type > & module_trace,
std::map< dindex, std::map< dindex, dindex > > & adj_list,
std::unordered_set< dindex > & obj_hashes )

Build an adjacency list from intersection traces.

Template Parameters
invalid_valueto keep the implementation simple, all indices are of type dindex here, but that does not need to be the case in the intersection code, so we need to know what the invalid value is interpreted as a dindex
entry_typethe record entry, which must contain the portal index and the volume index the portal was discovered in.
Parameters
portal_tracethe portal indices and their volume links (in adjacent portal pairs)
module_tracethe module indices and their volume links
adj_listadjacency list to populate
obj_hashesrecord which modules/portals were already added
Returns
an adjacency list from the traced ray scan of a given geometry.

◆ check_connectivity()

template<dindex invalid_value = dindex_invalid, bool check_sorted_trace = true, typename entry_type = std::pair<dindex, dindex>>
bool detray::detector_scanner::check_connectivity ( std::vector< std::pair< entry_type, entry_type > > trace,
dindex start_volume = 0u )

Check if a set of volume indices from portal intersections from a path (works even if the pairs are not sorted).

That the volume links of the portals at a single boundary crossing match was already checked by the trace_intersections function at this point.

For example, with (a, b) modeling a valid portal crossing between volume 'a' and 'b' (leaving out the portal indices that are also in those pairs), then: (0, 1)(1, 16)(16, 17) is valid, (0, 1)(1, 15)(16, 17) is not |__| |__| |_ |__| | x | |_

Also checks that the first portal that was found, lies in the start volume.

Template Parameters
invalid_valueto keep the implementation simple, all indices are of type dindex here, but that does not need to be the case in the intersection code, so we need to know what the invalid value is interpreted as a dindex
check_sorted_traceif the trace is not sorted, perform a search for a fitting record across the trace.
entry_typethe record entry, which must contain the portal index and the volume index the portal was discovered in.
Parameters
tracethe recorded portal crossings between volumes
start_volumewhere the ray started
Returns
true if the volumes indices form a connected chain.

◆ check_trace()

template<concepts::detector detector_t>
bool detray::detector_scanner::check_trace ( const dvector< intersection_record< detector_t > > & intersection_trace,
const dindex start_index,
dvector< dindex > & adj_mat_scan,
std::unordered_set< dindex > & obj_hashes )

Run all checks on an intersection trace.

Parameters
[in]intersection_tracethe intersection records along the track
[in]start_indexthe index of the intended start volume
[out]adj_mat_scanadjacency matrix to be filled for the detector
[out]obj_hashesobjects in a volume that were already visisted
Returns
true if the checks were successful

◆ display_error()

template<concepts::detector detector_t, typename trajectory_t>
void detray::detector_scanner::display_error ( const typename detector_t::geometry_context gctx,
const detector_t & det,
const typename detector_t::name_map & vol_names,
const std::string & test_name,
const trajectory_t & test_track,
const dvector< intersection_record< detector_t > > & truth_trace,
const detray::svgtools::styling::style & svg_style,
const std::size_t i_track,
const std::size_t n_tracks,
const dvector< intersection_record< detector_t > > & recorded_trace = {},
const dindex_range overlap_idx = {detray::detail::invalid_value<dindex>(), detray::detail::invalid_value<dindex>()},
const bool verbose = true )

Print the failed intersection trace as svg (dumped to files).

Parameters
gctxcurrent geometry context
detthe detector object
vol_namesthe volume name map of the detector
test_namethe name of the test for which to print the error
test_tracktrajectory that was used for the scan (ray or helix)
truth_tracethe intersection records along the test track
svg_stylesvgtools style for the detector display
i_trackindex of the test track
n_trackstotal number of test tracks
recorded_tracerecorded intersection trace, if available
overlap_idxrange of overlapping surfaces
verbosewhether to print failure details

◆ overlaps_removal()

template<concepts::detector detector_t>
dindex_range detray::detector_scanner::overlaps_removal ( dvector< intersection_record< detector_t > > & intersection_records,
const float tol = 1e-4f * unit<float>::mm )

Filter the intersection trace for overlapping surfaces and remove duplicates.

ACTS geometries can produce multiple overlapping portals, since some portals are larger than the volumes they belong to. This leads to duplicate intersections in the traces.

Parameters
[in,out]intersection_recordsIntersection trace to filter.
[in]tolMaximum path difference treated as an overlap.
Returns
Range of overlapping records, if any.

◆ print_adj()

std::string detray::detector_scanner::print_adj ( const dvector< dindex > & adjacency_matrix)

Print an adjacency list.

Parameters
adjacency_matrixAdjacency matrix to print.
Returns
Formatted adjacency list.

◆ print_trace()

template<concepts::detector detector_t>
std::string detray::detector_scanner::print_trace ( const dvector< intersection_record< detector_t > > & truth_trace,
std::size_t n )

Print an intersection trace.

Parameters
truth_traceIntersection trace to print.
nTrack number.
Returns
Formatted intersection trace.

◆ read()

template<concepts::detector detector_t, typename allocator_t>
auto detray::detector_scanner::read ( const std::string & intersection_file_name,
const std::string & track_param_file_name,
std::vector< std::vector< intersection_record< detector_t >, allocator_t > > & intersection_traces )

Read the intersection_record from file.

Parameters
intersection_file_nameIntersection input file name.
track_param_file_nameTrack parameter input file name.
intersection_tracesDestination for the read traces.
Returns
No value is returned.

◆ run()

template<template< typename > class scan_type, concepts::detector detector_t, typename trajectory_t, typename... Args>
auto detray::detector_scanner::run ( const typename detector_t::geometry_context gctx,
const detector_t & detector,
const trajectory_t & traj,
Args &&... args )

Run a scan on detector object by shooting test particles through it.

Parameters
gctxGeometry context for the scan.
detectorDetector to scan.
trajTrajectory to scan through the detector.
argsAdditional arguments forwarded to the scan.
Returns
Scan result.

◆ trace_intersections()

template<concepts::detector detector_t>
auto detray::detector_scanner::trace_intersections ( const dvector< intersection_record< detector_t > > & intersection_records,
dindex start_volume = 0u )

Check if a recording of portal/module intersections form a coherent trace through a geometry.

Various consistency checks are performed on the trace:

  • Was a surface intersected as part of the wrong volume?
  • Do the volume links at adjacent portals point at each other?
  • Is a portal crossing happening within a volume, as opposed to at its boundary surfaces?
  • Do portals always appear in pairs (exit + entry portal)?
Template Parameters
detector_tdifferent detector types for different metadata
Parameters
intersection_recordsthe recorded portal crossings between volumes
start_volumewhere the ray started
Note
the input record needs to be sorted according to the distance from the ray origin
Returns
a set of volume connections that were found by portal intersection of a ray.

◆ write_intersections()

template<concepts::detector detector_t, typename allocator_t>
auto detray::detector_scanner::write_intersections ( const std::string & intersection_file_name,
const std::vector< dvector< intersection_record< detector_t > >, allocator_t > & intersection_traces )

Write the intersection_traces to file.

Parameters
intersection_file_nameOutput file name.
intersection_tracesIntersection traces to write.
Returns
No value is returned.

◆ write_tracks()

template<concepts::detector detector_t, typename allocator_t>
auto detray::detector_scanner::write_tracks ( const std::string & track_param_file_name,
const std::vector< dvector< intersection_record< detector_t > >, allocator_t > & intersection_traces )

Write the intersection_traces to file.

Parameters
track_param_file_nameOutput file name.
intersection_tracesTraces containing the track parameters.
Returns
No value is returned.