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 // Function to combine Recoil layer points into "real" sensor points
73 std::pair<std::vector<std::tuple<std::array<double, 3>, ldmx::Measurement,
74 std::optional<ldmx::Measurement>>>,
75 std::vector<std::tuple<std::array<double, 3>, ldmx::Measurement,
76 std::optional<ldmx::Measurement>>>>
77 combineMultiGlobalHits(const std::vector<ldmx::Measurement> &hit_collection);
78
79 // Function to do weighted averaging when combining Recoil layer points
80 std::vector<std::tuple<std::array<double, 3>, ldmx::Measurement,
81 std::optional<ldmx::Measurement>>>
82 midPointCalculation(const std::vector<ldmx::Measurement> &layer1,
83 const std::vector<ldmx::Measurement> &layer2);
84
85 // Fitting function: fit a straight line in 3D using 3 points (1 degree of
86 // freedom)
87 std::tuple<double, double, double, double, std::vector<double>> fit3DLine(
88 const std::array<double, 3> &first_recoil,
89 const std::array<double, 3> &second_recoil,
90 const std::array<double, 3> &ecal);
91
92 // Helper function: calculate distance between 2 3D points
93 double calculateDistance(const std::array<double, 3> &point1,
94 const std::array<double, 3> &point2);
95
96 // Calculate chi2 of the fit
97 double globalChiSquare(const std::array<double, 3> &first_sensor,
98 const std::array<double, 3> &second_sensor,
99 const std::array<double, 3> &ecal_hit, double a_x,
100 double a_y, double b_x, double b_y);
101
102 // Function to find the number of unique layers hit (to determine if we have
103 // enough points to fit)
104 int uniqueLayersHit(const std::vector<ldmx::Measurement> &digi_points);
105
106 double processing_time_{0.};
107 long n_events_{0};
108 unsigned int n_seeds_{0};
109
111 std::string out_seed_collection_{"LinearRecoilSeedTracks"};
113 std::string input_hits_collection_{"DigiRecoilSimHits"};
115 std::string input_rec_hits_collection_{"EcalRecHits"};
116 std::string input_pass_name_{""};
117
118 double ecal_uncertainty_{3.87};
119 // Max distance from RecHit for valid track
120 double ecal_distance_threshold_{10.0};
121
122 // Assuming rLDMX_v1 geometry
123 double layer12_midpoint_{12.5};
124 double layer23_midpoint_{20.0};
125 double layer34_midpoint_{27.5};
126 double ecal_first_layer_z_threshold_{250.0};
127
128 std::vector<double> recoil_uncertainty_{0.006, 5.7735};
129
130 // Check failures
131 long n_missing_{0};
132
133 // Truth Matching tool
134 std::shared_ptr<tracking::sim::TruthMatchingTool> truth_matching_tool_ =
135 nullptr;
136
137}; // SeedFinderProcessor
138
139} // namespace reco
140} // 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
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
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...