LDMX Software
EcalTrackFinderProcessor.h
Go to the documentation of this file.
1
7#ifndef ECAL_ECALTRACKFINDERPROCESSOR_H_
8#define ECAL_ECALTRACKFINDERPROCESSOR_H_
9
10// LDMX
12#include "Ecal/Event/EcalHit.h"
13#include "Framework/Configure/Parameters.h"
15#include "Tracking/EigenStepper.h" // IWYU pragma: keep
16#include "Tracking/Event/Measurement.h"
17#include "Tracking/Event/Track.h"
18#include "Tracking/Sim/IndexSourceLink.h"
19
20// ACTS
21#include "Acts/Definitions/Algebra.hpp"
22#include "Acts/EventData/TrackContainer.hpp"
23#include "Acts/EventData/VectorMultiTrajectory.hpp"
24#include "Acts/EventData/VectorTrackContainer.hpp"
25#include "Acts/Geometry/GeometryIdentifier.hpp"
26#include "Acts/Geometry/TrackingGeometry.hpp"
27#include "Acts/Propagator/EigenStepper.hpp"
28#include "Acts/Propagator/Navigator.hpp"
29#include "Acts/Propagator/Propagator.hpp"
30#include "Acts/Surfaces/Surface.hpp"
31#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
32
33// C++
34#include <map>
35#include <memory>
36#include <unordered_map>
37#include <vector>
38
39namespace ecal {
40
53 public:
57 EcalTrackFinderProcessor(const std::string& name,
59
63 virtual ~EcalTrackFinderProcessor() = default;
64
68 void configure(framework::config::Parameters& parameters) override;
69
73 void onNewRun(const ldmx::RunHeader&) override;
74
78 void produce(framework::Event& event) override;
79
83 void onProcessEnd() override;
84
85 private:
89 std::vector<ldmx::Measurement> createMeasurements(
90 const std::vector<ldmx::EcalHit>& hits, std::vector<double>& energies);
91
95 void createEcalSurfaces();
96
100 std::vector<ldmx::Track> findSeeds(
101 const std::vector<ldmx::Measurement>& measurements);
102
107 std::tuple<Acts::Vector3, Acts::Vector3, double> fitStraightLine(
108 const std::vector<Acts::Vector3>& points);
109
113 std::unordered_multimap<Acts::GeometryIdentifier,
115 makeGeoIdSourceLinkMap(const std::vector<ldmx::Measurement>& measurements);
116
117 // Type aliases for ACTS objects
118 using EcalPropagator =
119 Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
120 using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
121 Acts::VectorMultiTrajectory>;
122
123 // ACTS objects
124 std::unique_ptr<const EcalPropagator> propagator_;
125 std::unique_ptr<
126 const Acts::CombinatorialKalmanFilter<EcalPropagator, TrackContainer>>
127 ckf_;
128
129 // ECAL layer surfaces (layer ID -> surface) - used during geometry building
130 std::map<int, std::shared_ptr<Acts::Surface>> layer_surfaces_;
131
132 // Mapping from ECAL layer ID to the GeometryIdentifier assigned by the
133 // TrackingGeometryBuilder. These IDs are what the CKF Navigator sees when
134 // it reaches a surface, so source links must be keyed by these IDs.
135 std::map<int, Acts::GeometryIdentifier> layer_geo_ids_;
136
137 // Reference surface (ECAL front face)
138 std::shared_ptr<Acts::Surface> reference_surface_;
139
140 // ACTS tracking geometry for ECAL
141 std::shared_ptr<const Acts::TrackingGeometry> tracking_geometry_;
142
143 // Rotation matrix for surface orientation (u=Y, v=Z, normal=X in ACTS)
144 Acts::RotationMatrix3 surf_rotation_;
145
146 // Configuration parameters
147 std::string rec_coll_name_{"EcalRecHits"};
148 std::string rec_pass_name_{""};
149 std::string out_track_collection_{"EcalTracks"};
150 int min_hits_{3}; // Minimum hits per track
151 double max_chi2_{10.0}; // Outlier chi2 cut
152 double cell_resolution_{1.5}; // ECAL cell resolution [mm]
153 bool debug_{false}; // ACTS debug logging
154
155 // Seed finding parameters
156 double max_seed_rms_{10.0}; // Max RMS for seed fit [mm]
157 double min_momentum_{50.0}; // Min momentum estimate [MeV]
158 double max_momentum_{10000.0}; // Max momentum estimate [MeV]
159
160 // ROC cone energy collection
161 bool use_roc_energy_{true}; // Use 68% containment cone for track energy
162 std::string roc_file_name_; // Path to ROC containment radii CSV file
163 std::vector<std::vector<float>> roc_range_values_; // ROC data from file
164
165 // Geometry
166 const ldmx::EcalGeometry* geometry_{nullptr};
167
168 // Statistics
169 int nevents_{0};
170 int ntracks_{0};
171 int nseeds_{0};
172 double processing_time_{0.0};
173};
174
175} // namespace ecal
176
177#endif // ECAL_ECALTRACKFINDERPROCESSOR_H_
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
The only reason this file exists is to silence an annoying maybe-uninitialized warning that originate...
Base classes for all user event processing components to extend.
Uses ACTS framework to fit tracks through ECAL hits with zero B-field.
virtual ~EcalTrackFinderProcessor()=default
Destructor.
EcalTrackFinderProcessor(const std::string &name, framework::Process &process)
Constructor.
void onNewRun(const ldmx::RunHeader &) override
Initialize ACTS tracking objects once the detector geometry is known.
std::vector< ldmx::Measurement > createMeasurements(const std::vector< ldmx::EcalHit > &hits, std::vector< double > &energies)
Create ACTS measurement objects from ECAL hits.
std::unordered_multimap< Acts::GeometryIdentifier, acts_examples::IndexSourceLink > makeGeoIdSourceLinkMap(const std::vector< ldmx::Measurement > &measurements)
Create geometry ID to source link map for CKF.
std::tuple< Acts::Vector3, Acts::Vector3, double > fitStraightLine(const std::vector< Acts::Vector3 > &points)
Fit straight line through 3D points Returns: (position, direction, RMS residual)
void produce(framework::Event &event) override
Process event to find ECAL tracks.
void configure(framework::config::Parameters &parameters) override
Configure the processor.
std::vector< ldmx::Track > findSeeds(const std::vector< ldmx::Measurement > &measurements)
Find seed tracks via straight-line fitting.
void createEcalSurfaces()
Create unbounded plane surfaces at each ECAL layer.
void onProcessEnd() override
Print statistics.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class which represents the process under execution.
Definition Process.h:34
Base class for a module which produces a data product.
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
Translation between real-space positions and cell IDs within the ECal.
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:68