1#include "Tracking/Reco/LinearTrackFinder.h"
20 parameters.
get<std::string>(
"seed_collection",
"LinearRecoilSeedTracks");
23 parameters.
get<std::string>(
"out_trk_collection",
"LinearRecoilTracks");
25 input_pass_name_ = parameters.
get<std::string>(
"input_pass_name");
30 std::vector<ldmx::StraightTrack> straight_tracks;
32 auto start = std::chrono::high_resolution_clock::now();
35 if (n_events_ % 1000 == 0) ldmx_log(info) <<
"events processed:" << n_events_;
37 ldmx_log(debug) <<
"Retrieve the seeds::" << seed_collection_;
40 seed_collection_, input_pass_name_);
42 n_seeds_ = seed_tracks.size();
43 ldmx_log(debug) <<
"Number of seeds::" << n_seeds_;
46 straight_tracks = findTracks(seed_tracks);
49 n_tracks_ += straight_tracks.size();
52 event.add(out_trk_collection_, straight_tracks);
54 auto end = std::chrono::high_resolution_clock::now();
55 auto diff = end - start;
56 processing_time_ += std::chrono::duration<double, std::milli>(diff).count();
58 straight_tracks.clear();
62 ldmx_log(info) <<
"found " << n_tracks_ <<
" tracks / " << n_events_
64 ldmx_log(info) <<
"AVG Time/Event: " << std::fixed << std::setprecision(1)
65 << processing_time_ / n_events_ <<
" ms";
68std::vector<ldmx::StraightTrack> LinearTrackFinder::findTracks(
69 const std::vector<ldmx::StraightTrack>& track_seeds) {
70 std::vector<ldmx::StraightTrack> best_tracks;
71 std::map<std::array<double, 3>, std::vector<ldmx::StraightTrack>>
75 for (
const auto& seed : track_seeds) {
76 auto rec_hit_point = seed.getFirstLayerEcalRecHit();
77 seeds_by_rec_hit[rec_hit_point].push_back(seed);
81 std::set<std::tuple<float, float, float>> used_sensor_positions;
85 for (
auto& entry : seeds_by_rec_hit) {
86 const auto& rec_hit_point = entry.first;
87 auto& seeds_with_same_rec_hit = entry.second;
89 ldmx_log(debug) <<
"Processing RecHit at: (" << rec_hit_point[0] <<
", "
90 << rec_hit_point[1] <<
", " << rec_hit_point[2] <<
")\n";
93 seeds_with_same_rec_hit.erase(
95 seeds_with_same_rec_hit.begin(), seeds_with_same_rec_hit.end(),
97 for (const auto& measurement : seed.getAllSensorPoints()) {
99 if (isPositionUsed(measurement, used_sensor_positions)) {
107 seeds_with_same_rec_hit.end());
110 if (seeds_with_same_rec_hit.empty())
continue;
113 auto best_seed_it = std::min_element(
114 seeds_with_same_rec_hit.begin(), seeds_with_same_rec_hit.end(),
116 return trk_a.getChi2() < trk_b.getChi2();
121 best_tracks.push_back(best_seed);
123 ldmx_log(debug) <<
"For RecHit at: (" << rec_hit_point[0] <<
", "
124 << rec_hit_point[1] <<
", " << rec_hit_point[2] <<
")\n";
127 auto best_seed_measurement = best_seed.getAllSensorPoints();
129 for (
auto& position_object : best_seed_measurement) {
130 used_sensor_positions.insert(
131 std::make_tuple(position_object.getGlobalPosition()[0],
132 position_object.getGlobalPosition()[1],
133 position_object.getGlobalPosition()[2]));
134 ldmx_log(debug) <<
"We used the following point: ("
135 << position_object.getGlobalPosition()[0] <<
", "
136 << position_object.getGlobalPosition()[1] <<
", "
137 << position_object.getGlobalPosition()[2] <<
")\n";
138 ldmx_log(debug) <<
"Which gave a track a distance: "
139 << best_seed.getDistanceToRecHit()
140 <<
" to the closest ECalRecHit\n";
150bool LinearTrackFinder::isPositionUsed(
152 const std::set<std::tuple<float, float, float>>& used_sensor_positions) {
157 return used_sensor_positions.find(position) != used_sensor_positions.end();
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Implements an event buffer system for storing event data.
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
std::array< float, 3 > getGlobalPosition() const
void onProcessEnd() override
Output event statistics.
LinearTrackFinder(const std::string &name, framework::Process &process)
Constructor.
void configure(framework::config::Parameters ¶meters) override
Configure the processor using the given user specified parameters.
void produce(framework::Event &event) override
Run the processor.
a helper base class providing some methods to shorten access to common conditions used within the tra...
The measurement calibrator can be a function or a class/struct able to retrieve the sim hits containe...