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 "DetDescr/EcalID.h"
13#include "Ecal/Event/EcalHit.h"
14#include "Framework/Configure/Parameters.h"
16#include "Tracking/EigenStepper.h" // help silence and internal warning
17#include "Tracking/Event/Measurement.h"
18#include "Tracking/Event/Track.h"
19#include "Tracking/Sim/IndexSourceLink.h"
20
21// ACTS
22#include "Acts/Definitions/Algebra.hpp"
23#include "Acts/Definitions/TrackParametrization.hpp"
24#include "Acts/EventData/TrackContainer.hpp"
25#include "Acts/EventData/VectorMultiTrajectory.hpp"
26#include "Acts/EventData/VectorTrackContainer.hpp"
27#include "Acts/Geometry/GeometryIdentifier.hpp"
28#include "Acts/Geometry/TrackingGeometry.hpp"
29#include "Acts/MagneticField/ConstantBField.hpp"
30#include "Acts/Material/HomogeneousVolumeMaterial.hpp"
31#include "Acts/Propagator/EigenStepper.hpp"
32#include "Acts/Propagator/Navigator.hpp"
33#include "Acts/Propagator/Propagator.hpp"
34#include "Acts/Surfaces/PlaneSurface.hpp"
35#include "Acts/Surfaces/RectangleBounds.hpp"
36#include "Acts/Surfaces/Surface.hpp"
37#include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
38#include "Acts/TrackFitting/GainMatrixUpdater.hpp"
39
40// C++
41#include <map>
42#include <memory>
43#include <unordered_map>
44#include <vector>
45
46namespace ecal {
47
60 public:
64 EcalTrackFinderProcessor(const std::string& name,
66
70 virtual ~EcalTrackFinderProcessor() = default;
71
75 void configure(framework::config::Parameters& parameters) override;
76
80 void onNewRun(const ldmx::RunHeader&) override;
81
85 void produce(framework::Event& event) override;
86
90 void onProcessEnd() override;
91
92 private:
96 std::vector<ldmx::Measurement> createMeasurements(
97 const std::vector<ldmx::EcalHit>& hits, std::vector<double>& energies);
98
102 void createEcalSurfaces();
103
107 std::vector<ldmx::Track> findSeeds(
108 const std::vector<ldmx::Measurement>& measurements);
109
114 std::tuple<Acts::Vector3, Acts::Vector3, double> fitStraightLine(
115 const std::vector<Acts::Vector3>& points);
116
120 std::unordered_multimap<Acts::GeometryIdentifier,
122 makeGeoIdSourceLinkMap(const std::vector<ldmx::Measurement>& measurements);
123
124 // Type aliases for ACTS objects
125 using EcalPropagator =
126 Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
127 using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
128 Acts::VectorMultiTrajectory>;
129
130 // ACTS objects
131 std::unique_ptr<const EcalPropagator> propagator_;
132 std::unique_ptr<
133 const Acts::CombinatorialKalmanFilter<EcalPropagator, TrackContainer>>
134 ckf_;
135
136 // ECAL layer surfaces (layer ID -> surface) - used during geometry building
137 std::map<int, std::shared_ptr<Acts::Surface>> layer_surfaces_;
138
139 // Mapping from ECAL layer ID to the GeometryIdentifier assigned by the
140 // TrackingGeometryBuilder. These IDs are what the CKF Navigator sees when
141 // it reaches a surface, so source links must be keyed by these IDs.
142 std::map<int, Acts::GeometryIdentifier> layer_geo_ids_;
143
144 // Reference surface (ECAL front face)
145 std::shared_ptr<Acts::Surface> reference_surface_;
146
147 // ACTS tracking geometry for ECAL
148 std::shared_ptr<const Acts::TrackingGeometry> tracking_geometry_;
149
150 // Rotation matrix for surface orientation (u=Y, v=Z, normal=X in ACTS)
151 Acts::RotationMatrix3 surf_rotation_;
152
153 // Configuration parameters
154 std::string rec_coll_name_{"EcalRecHits"};
155 std::string rec_pass_name_{""};
156 std::string out_track_collection_{"EcalTracks"};
157 int min_hits_{3}; // Minimum hits per track
158 double max_chi2_{10.0}; // Outlier chi2 cut
159 double cell_resolution_{1.5}; // ECAL cell resolution [mm]
160 bool debug_{false}; // ACTS debug logging
161
162 // Seed finding parameters
163 double max_seed_rms_{10.0}; // Max RMS for seed fit [mm]
164 double min_momentum_{50.0}; // Min momentum estimate [MeV]
165 double max_momentum_{10000.0}; // Max momentum estimate [MeV]
166
167 // ROC cone energy collection
168 bool use_roc_energy_{true}; // Use 68% containment cone for track energy
169 std::string roc_file_name_; // Path to ROC containment radii CSV file
170 std::vector<std::vector<float>> roc_range_values_; // ROC data from file
171
172 // Geometry
173 const ldmx::EcalGeometry* geometry_{nullptr};
174
175 // Statistics
176 int nevents_{0};
177 int ntracks_{0};
178 int nseeds_{0};
179 double processing_time_{0.0};
180};
181
182} // namespace ecal
183
184#endif // ECAL_ECALTRACKFINDERPROCESSOR_H_
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
Class that defines an ECal detector ID with a cell number.
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:42
Class which represents the process under execution.
Definition Process.h:37
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:29
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:57