LDMX Software
LinearSeedFinder.h
1#pragma once
2
3//---< Framework >---//
4#include "Framework/Configure/Parameters.h"
5#include "Framework/Event.h"
7
8//---< SimCore >---//
10
11//---< STD C++ >---//
12
13//--- LDMX ---//
14#include "Tracking/Event/Measurement.h"
15#include "Tracking/Event/StraightTrack.h"
16#include "Tracking/Reco/TrackingGeometryUser.h"
17#include "Tracking/Reco/TruthMatchingTool.h"
18
19namespace tracking {
20namespace reco {
21
23 public:
30 LinearSeedFinder(const std::string& name, framework::Process& process);
31
33 virtual ~LinearSeedFinder() = default;
37 void onProcessStart() override;
41 void onProcessEnd() override;
47 void configure(framework::config::Parameters& parameters) override;
48
55 void produce(framework::Event& event) override;
56
57 protected:
58 // Function to find seeds based on 2 Recoil points and 1 EcalRecHit
59 ldmx::StraightTrack seedTracker(
60 const std::tuple<std::array<double, 3>, ldmx::Measurement,
61 std::optional<ldmx::Measurement>>
62 recoil_one,
63 const std::tuple<std::array<double, 3>, ldmx::Measurement,
64 std::optional<ldmx::Measurement>>
65 recoil_two,
66 const std::array<double, 3> ecal_one);
67
68 // Fitting function: fit a straight line in 3D using 3 points (1 degree of
69 // freedom)
70 std::tuple<double, double, double, double, std::vector<double>> fit3DLine(
71 const std::array<double, 3>& first_recoil,
72 const std::array<double, 3>& second_recoil,
73 const std::array<double, 3>& ecal);
74
75 // Helper function: calculate distance between 2 3D points
76 double calculateDistance(const std::array<double, 3>& point1,
77 const std::array<double, 3>& point2);
78
79 // Do 3D hit reconstruction using an axial measurement and a stereo
80 // measurement according to geometric projections
81 Acts::Vector3 simple3DHitV2(const ldmx::Measurement& axial,
82 const Acts::Surface& axial_surface,
83 const ldmx::Measurement& stereo,
84 const Acts::Surface& stereo_surface,
85 const ldmx::SimTrackerHit& hitOnTarget,
86 std::vector<ldmx::SimTrackerHit> pair_sim_hits);
87
88 // Makes all combinations of sensor measurements to use in the seeding
89 std::vector<std::tuple<
90 std::array<double, 3>,
91 std::tuple<ldmx::Measurement, ldmx::SimTrackerHit, ldmx::SimTrackerHit>,
92 std::optional<std::tuple<ldmx::Measurement, ldmx::SimTrackerHit,
94 processMeasurements(
95 const std::vector<std::tuple<ldmx::Measurement, ldmx::SimTrackerHit,
96 ldmx::SimTrackerHit>>& measurements,
98
99 // Calculate chi2 of the fit
100 double globalChiSquare(const std::array<double, 3>& first_sensor,
101 const std::array<double, 3>& second_sensor,
102 const std::array<double, 3>& ecal_hit, double a_x,
103 double a_y, double b_x, double b_y);
104
105 // Function to find the number of unique layers hit (to determine if we have
106 // enough points to fit)
107 int uniqueLayersHit(const std::vector<ldmx::Measurement>& digi_points);
108
109 // Helper functions:
110 std::array<double, 3> convertToLdmxStdArray(const Acts::Vector3& vec);
111 std::tuple<Acts::Vector3, Acts::Vector3, Acts::Vector3> getSurfaceVectors(
112 const Acts::Surface& surface);
113 double dotProduct(const Acts::Vector3& v1, const Acts::Vector3& v2);
114 std::array<double, 3> getPointAtZ(std::array<double, 3> target,
115 std::array<double, 3> measurement,
116 double z_target);
117
118 double processing_time_{0.};
119 long n_events_{0};
120 unsigned int n_seeds_{0};
121
123 std::string out_seed_collection_{"LinearRecoilSeedTracks"};
125 std::string input_hits_collection_{"DigiRecoilSimHits"};
127 std::string input_rec_hits_collection_{"EcalRecHits"};
128 std::string input_pass_name_{""};
129
130 double ecal_uncertainty_{3.87};
131 // Max distance from RecHit for valid track
132 double ecal_distance_threshold_{10.0};
133
134 // Assuming rLDMX_v1 geometry
135 double layer12_midpoint_{12.5};
136 double layer23_midpoint_{20.0};
137 double layer34_midpoint_{27.5};
138 double ecal_first_layer_z_threshold_{250.0};
139
140 std::vector<double> recoil_uncertainty_{0.006, 0.085};
141
142 // Check failures
143 long n_missing_{0};
144
145 // Truth Matching tool
146 std::shared_ptr<tracking::sim::TruthMatchingTool> truth_matching_tool_ =
147 nullptr;
148
149 private:
150 std::string next_event_passname_;
151 std::string sim_particles_passname_;
152 std::string sim_particles_events_passname_;
153
154}; // SeedFinderProcessor
155
156} // namespace reco
157} // namespace tracking
Base classes for all user event processing components to extend.
Class implementing an event buffer system for storing event data.
Class which encapsulates information from a hit in a simulated tracking detector.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class which represents the process under execution.
Definition Process.h:34
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:26
Represents a simulated tracker hit in the simulation.
std::string out_seed_collection_
The name of the output collection of seeds to be stored.
LinearSeedFinder(const std::string &name, framework::Process &process)
Constructor.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
virtual ~LinearSeedFinder()=default
Destructor.
void produce(framework::Event &event) override
Run the processor and create a collection of results which indicate if a charge particle can be found...
void onProcessEnd() override
Output event statistics.
std::string input_hits_collection_
The name of the input hits collection to use in finding seeds..
void onProcessStart() override
Setup the truth matching.
std::string input_rec_hits_collection_
The name of the tagger Tracks (only for Recoil Seeding)
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...