LDMX Software
GreedyAmbiguitySolver.h
1#pragma once
2
3//--- Framework ---//
4#include "Framework/Configure/Parameters.h"
7
8//--- C++ ---//
9#include <memory>
10#include <random>
11
12//--- LDMX ---//
13#include "Tracking/Reco/TrackingGeometryUser.h"
14
15//--- ACTS ---//
16
17// Utils and Definitions
18#include "Acts/Definitions/Common.hpp"
19#include "Acts/Utilities/Logger.hpp"
20
21// geometry
22#include "Acts/Geometry/GeometryContext.hpp"
23
24// geometry
25#include <Acts/Geometry/TrackingGeometry.hpp>
26
27#include "Acts/Geometry/GeometryIdentifier.hpp"
28
29//--- Tracking ---//
30#include "Tracking/Event/Measurement.h"
31#include "Tracking/Event/Track.h"
32#include "Tracking/Reco/TrackExtrapolatorTool.h"
33#include "Tracking/Sim/IndexSourceLink.h"
34#include "Tracking/Sim/MeasurementCalibrator.h"
35#include "Tracking/Sim/TrackingUtils.h"
36
37//--- Interpolated magnetic field ---//
38#include "Tracking/Sim/BFieldXYZUtils.h"
39
40namespace tracking {
41namespace reco {
42
50 public:
58 GreedyAmbiguitySolver(const std::string& name, framework::Process& process);
59
61 virtual ~GreedyAmbiguitySolver() = default;
62
69 void onNewRun(const ldmx::RunHeader& rh) override;
70
80 void configure(framework::config::Parameters& parameters) override;
81
87 void produce(framework::Event& event) override;
88
89 void onProcessEnd() override;
90
91 private:
92 int nevents_{0};
93 int n_input_tracks_{0};
94 int n_output_tracks_{0};
95 double processing_time_{0.};
96
98 std::uint32_t maximum_shared_hits_{1};
100 std::uint32_t maximum_iterations_{1000};
101
103 std::size_t n_meas_min_{7};
104
105 std::string out_trk_collection_{"TaggerTracksClean"};
106
107 std::string track_collection_{"TaggerTracks"};
108
109 std::string meas_collection_{"DigiTaggerSimHits"};
110
111 std::string input_pass_name_{""};
112
113 struct State {
114 std::size_t number_of_tracks_{};
115
116 std::vector<int> track_tips_;
117 std::vector<float> track_chi2_;
118 std::vector<std::vector<std::size_t>> measurements_per_track_;
119
120 // TODO consider boost 1.81 unordered_flat_map
121 boost::container::flat_map<std::size_t,
122 boost::container::flat_set<std::size_t>>
123 tracks_per_measurement_;
124 std::vector<std::size_t> shared_measurements_per_track_;
125
126 // TODO consider boost 1.81 unordered_flat_map
127 boost::container::flat_set<std::size_t> selected_tracks_;
128 };
129
136 template <typename geometry_t, typename source_link_hash_t,
137 typename source_link_equality_t>
138 void computeInitialState(std::vector<ldmx::Track> tracks,
139 std::vector<ldmx::Measurement> measurements,
140 State& state, geometry_t& tg,
141 source_link_hash_t&& sourceLinkHash,
142 source_link_equality_t&& sourceLinkEquality) const;
143
149 void resolve(State& state);
150
154 void removeTrack(State& state, std::size_t iTrack) const;
155
156 /*
158 std::size_t sourceLinkHash(const Acts::SourceLink& a);
159
162 bool sourceLinkEquality(const Acts::SourceLink& a, const Acts::SourceLink& b);
163 */
164
165}; // MyProcessor
166
167} // namespace reco
168} // namespace tracking
Base classes for all user event processing components to extend.
Conditions object for random number seeds.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:57
Minimal example of a processor.
GreedyAmbiguitySolver(const std::string &name, framework::Process &process)
Constructor.
std::size_t n_meas_min_
Minimum number of measurement to form a track.
void removeTrack(State &state, std::size_t iTrack) const
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
void computeInitialState(std::vector< ldmx::Track > tracks, std::vector< ldmx::Measurement > measurements, State &state, geometry_t &tg, source_link_hash_t &&sourceLinkHash, source_link_equality_t &&sourceLinkEquality) const
void resolve(State &state)
Updates the state iteratively by evicting one track after the other until the final state conditions ...
void onNewRun(const ldmx::RunHeader &rh) override
onNewRun is the first function called for each processor after the conditions are fully configured an...
virtual ~GreedyAmbiguitySolver()=default
Destructor.
void produce(framework::Event &event) override
Process the event and put new data products into it.
std::uint32_t maximum_iterations_
Maximum number of iterations.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
std::uint32_t maximum_shared_hits_
Maximum amount of shared hits per track.
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...