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#include <iostream>
13
14//--- LDMX ---//
15#include "Ecal/Event/EcalHit.h"
16#include "TFile.h"
17#include "TTree.h"
18#include "Tracking/Event/Measurement.h"
19#include "Tracking/Event/StraightTrack.h"
20#include "Tracking/Reco/TrackingGeometryUser.h"
21#include "Tracking/Reco/TruthMatchingTool.h"
22
23namespace tracking {
24namespace reco {
25
27 public:
34 LinearSeedFinder(const std::string &name, framework::Process &process);
35
37 virtual ~LinearSeedFinder() = default;
41 void onProcessStart() override;
45 void onProcessEnd() override;
51 void configure(framework::config::Parameters &parameters) override;
52
59 void produce(framework::Event &event) override;
60
61 protected:
62 // Function to find seeds based on 2 Recoil points and 1 EcalRecHit
63 ldmx::StraightTrack seedTracker(
64 const std::tuple<std::array<double, 3>, ldmx::Measurement,
65 std::optional<ldmx::Measurement>>
66 recoil_one,
67 const std::tuple<std::array<double, 3>, ldmx::Measurement,
68 std::optional<ldmx::Measurement>>
69 recoil_two,
70 const std::array<double, 3> ecal_one);
71
72 // Fitting function: fit a straight line in 3D using 3 points (1 degree of
73 // freedom)
74 std::tuple<double, double, double, double, std::vector<double>> fit3DLine(
75 const std::array<double, 3> &first_recoil,
76 const std::array<double, 3> &second_recoil,
77 const std::array<double, 3> &ecal);
78
79 // Helper function: calculate distance between 2 3D points
80 double calculateDistance(const std::array<double, 3> &point1,
81 const std::array<double, 3> &point2);
82
83 // Do 3D hit reconstruction using an axial measurement and a stereo
84 // measurement according to geometric projections
85 Acts::Vector3 simple3DHitV2(const ldmx::Measurement &axial,
86 const Acts::Surface &axial_surface,
87 const ldmx::Measurement &stereo,
88 const Acts::Surface &stereo_surface,
89 const ldmx::SimTrackerHit &hitOnTarget,
90 std::vector<ldmx::SimTrackerHit> pair_sim_hits);
91
92 // Makes all combinations of sensor measurements to use in the seeding
93 std::vector<std::tuple<
94 std::array<double, 3>,
95 std::tuple<ldmx::Measurement, ldmx::SimTrackerHit, ldmx::SimTrackerHit>,
96 std::optional<std::tuple<ldmx::Measurement, ldmx::SimTrackerHit,
98 processMeasurements(
99 const std::vector<std::tuple<ldmx::Measurement, ldmx::SimTrackerHit,
100 ldmx::SimTrackerHit>> &measurements,
102
103 // Calculate chi2 of the fit
104 double globalChiSquare(const std::array<double, 3> &first_sensor,
105 const std::array<double, 3> &second_sensor,
106 const std::array<double, 3> &ecal_hit, double a_x,
107 double a_y, double b_x, double b_y);
108
109 // Function to find the number of unique layers hit (to determine if we have
110 // enough points to fit)
111 int uniqueLayersHit(const std::vector<ldmx::Measurement> &digi_points);
112
113 // Helper functions:
114 std::array<double, 3> convertToLdmxStdArray(const Acts::Vector3 &vec);
115 std::tuple<Acts::Vector3, Acts::Vector3, Acts::Vector3> getSurfaceVectors(
116 const Acts::Surface &surface);
117 double dotProduct(const Acts::Vector3 &v1, const Acts::Vector3 &v2);
118 std::array<double, 3> getPointAtZ(std::array<double, 3> target,
119 std::array<double, 3> measurement,
120 double z_target);
121
122 double processing_time_{0.};
123 long n_events_{0};
124 unsigned int n_seeds_{0};
125
127 std::string out_seed_collection_{"LinearRecoilSeedTracks"};
129 std::string input_hits_collection_{"DigiRecoilSimHits"};
131 std::string input_rec_hits_collection_{"EcalRecHits"};
132 std::string input_pass_name_{""};
133
134 double ecal_uncertainty_{3.87};
135 // Max distance from RecHit for valid track
136 double ecal_distance_threshold_{10.0};
137
138 // Assuming rLDMX_v1 geometry
139 double layer12_midpoint_{12.5};
140 double layer23_midpoint_{20.0};
141 double layer34_midpoint_{27.5};
142 double ecal_first_layer_z_threshold_{250.0};
143
144 std::vector<double> recoil_uncertainty_{0.006, 0.085};
145
146 // Check failures
147 long n_missing_{0};
148
149 // Truth Matching tool
150 std::shared_ptr<tracking::sim::TruthMatchingTool> truth_matching_tool_ =
151 nullptr;
152
153 private:
154 std::string next_event_passname_;
155 std::string sim_particles_passname_;
156 std::string sim_particles_events_passname_;
157
158}; // SeedFinderProcessor
159
160} // namespace reco
161} // 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:42
Class which represents the process under execution.
Definition Process.h:36
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
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...