1#include "Tracking/Reco/LinearTrackFinder.h"
21 seed_collection_ = parameters.getParameter<std::string>(
22 "seed_collection",
"LinearRecoilSeedTracks");
24 out_trk_collection_ = parameters.getParameter<std::string>(
25 "out_trk_collection",
"LinearRecoilTracks");
28 parameters.getParameter<std::string>(
"input_pass_name",
"");
33 std::vector<ldmx::StraightTrack> straight_tracks;
35 auto start = std::chrono::high_resolution_clock::now();
38 if (n_events_ % 1000 == 0) ldmx_log(info) <<
"events processed:" << n_events_;
40 ldmx_log(debug) <<
"Retrieve the seeds::" << seed_collection_;
42 const std::vector<ldmx::StraightTrack> seed_tracks =
46 n_seeds_ = seed_tracks.size();
47 ldmx_log(debug) <<
"Number of seeds::" << n_seeds_;
50 straight_tracks = findTracks(seed_tracks);
53 n_tracks_ += straight_tracks.size();
56 event.add(out_trk_collection_, straight_tracks);
58 auto end = std::chrono::high_resolution_clock::now();
59 auto diff = end - start;
60 processing_time_ += std::chrono::duration<double, std::milli>(diff).count();
62 straight_tracks.clear();
66 ldmx_log(info) <<
"found " << n_tracks_ <<
" tracks / " << n_events_
68 ldmx_log(info) <<
"AVG Time/Event: " << std::fixed << std::setprecision(1)
69 << processing_time_ / n_events_ <<
" ms";
72std::vector<ldmx::StraightTrack> LinearTrackFinder::findTracks(
73 const std::vector<ldmx::StraightTrack>& track_seeds) {
74 std::vector<ldmx::StraightTrack> best_tracks;
75 std::map<std::array<double, 3>, std::vector<ldmx::StraightTrack>>
79 for (
const auto& seed : track_seeds) {
80 auto rec_hit_point = seed.getFirstLayerEcalRecHit();
81 seeds_by_rec_hit[rec_hit_point].push_back(seed);
85 std::set<std::tuple<float, float, float>> used_sensor_positions;
89 for (
auto& entry : seeds_by_rec_hit) {
90 const auto& rec_hit_point = entry.first;
91 auto& seeds_with_same_rec_hit = entry.second;
93 ldmx_log(debug) <<
"Processing RecHit at: (" << rec_hit_point[0] <<
", "
94 << rec_hit_point[1] <<
", " << rec_hit_point[2] <<
")\n";
97 seeds_with_same_rec_hit.erase(
99 seeds_with_same_rec_hit.begin(), seeds_with_same_rec_hit.end(),
101 for (const auto& measurement : seed.getAllSensorPoints()) {
103 if (isPositionUsed(measurement, used_sensor_positions)) {
111 seeds_with_same_rec_hit.end());
114 if (seeds_with_same_rec_hit.empty())
continue;
117 auto best_seed_it = std::min_element(
118 seeds_with_same_rec_hit.begin(), seeds_with_same_rec_hit.end(),
120 return trk_a.getChi2() < trk_b.getChi2();
125 best_tracks.push_back(best_seed);
127 ldmx_log(debug) <<
"For RecHit at: (" << rec_hit_point[0] <<
", "
128 << rec_hit_point[1] <<
", " << rec_hit_point[2] <<
")\n";
131 auto best_seed_measurement = best_seed.getAllSensorPoints();
133 for (
auto& position_object : best_seed_measurement) {
134 used_sensor_positions.insert(
135 std::make_tuple(position_object.getGlobalPosition()[0],
136 position_object.getGlobalPosition()[1],
137 position_object.getGlobalPosition()[2]));
138 ldmx_log(debug) <<
"We used the following point: ("
139 << position_object.getGlobalPosition()[0] <<
", "
140 << position_object.getGlobalPosition()[1] <<
", "
141 << position_object.getGlobalPosition()[2] <<
")\n";
142 ldmx_log(debug) <<
"Which gave a track a distance: "
143 << best_seed.getDistanceToRecHit()
144 <<
" to the closest ECalRecHit\n";
154bool LinearTrackFinder::isPositionUsed(
156 const std::set<std::tuple<float, float, float>>& used_sensor_positions) {
161 return used_sensor_positions.find(position) != used_sensor_positions.end();
#define DECLARE_PRODUCER_NS(NS, 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.
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...