LDMX Software
TruthSeedProcessor.h
1#pragma once
2
3//--- Framework ---//
4#include "Framework/Configure/Parameters.h"
6#include "Framework/Logger.h"
7#include "SimCore/Event/SimParticle.h"
9
10// --- Tracking --- //
11#include "Tracking/EigenStepper.h" // IWYU pragma: keep
12#include "Tracking/Event/Track.h"
13#include "Tracking/Reco/TrackExtrapolatorTool.h"
14#include "Tracking/Reco/TrackingGeometryUser.h"
15
16// --- ACTS --- //
17#include <random>
18
19#include "Acts/Propagator/Navigator.hpp"
20#include "Acts/Propagator/Propagator.hpp"
21
22using TruthPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
23
24namespace tracking::reco {
25
37 public:
45 TruthSeedProcessor(const std::string& name, framework::Process& process);
46
48 virtual ~TruthSeedProcessor() = default;
49
60 void configure(framework::config::Parameters& parameters) override;
61
67 void onProcessStart() override {};
68
75 void onNewRun(const ldmx::RunHeader& rh) override;
76
83 void produce(framework::Event& event) override;
84
85 private:
93 void makeHitCountMap(const std::vector<ldmx::SimTrackerHit>& sim_hits,
94 std::map<int, std::vector<int>>& hit_count_map);
95
102 void createTruthTrack(const ldmx::SimParticle& particle, ldmx::Track& trk,
103 const std::shared_ptr<Acts::Surface>& target_surface);
104
113 void createTruthTrack(const ldmx::SimParticle& particle,
114 const ldmx::SimTrackerHit& hit, ldmx::Track& trk,
115 const std::shared_ptr<Acts::Surface>& target_surface);
116
126 void createTruthTrack(const std::vector<double>& pos_vec,
127 const std::vector<double>& p_vec, int charge,
128 ldmx::Track& trk,
129 const std::shared_ptr<Acts::Surface>& target_surface);
130
140 const ldmx::SimTrackerHit& hit,
141 const std::vector<ldmx::SimTrackerHit>& ecal_sp_hits);
142
149 ldmx::Track seedFromTruth(const ldmx::Track& tt, bool seed_smearing);
150
151 ldmx::Track recoilFullSeed(
152 const ldmx::SimParticle& particle, const int trackID,
153 const ldmx::SimTrackerHit& hit, const ldmx::SimTrackerHit& ecal_hit,
154 const std::map<int, std::vector<int>>& hit_count_map,
155 const std::shared_ptr<Acts::Surface>& origin_surface,
156 const std::shared_ptr<Acts::Surface>& target_surface,
157 const std::shared_ptr<Acts::Surface>& ecal_surface);
158
179 const ldmx::SimParticle& beam_electron, const int trackID,
180 const ldmx::SimTrackerHit& hit,
181 const std::map<int, std::vector<int>>& hit_count_map,
182 const std::shared_ptr<Acts::Surface>& origin_surface,
183 const std::shared_ptr<Acts::Surface>& target_surface);
184
186 std::vector<int> pdg_ids_{11};
187
189 std::string scoring_hits_coll_name_{"TargetScoringPlaneHits"};
190 std::string ecal_sp_coll_name_{"EcalScoringPlaneHits"};
191 std::string sp_pass_name_{""};
192
194 std::string tagger_sim_hits_coll_name_{"TaggerSimHits"};
195
197 std::string recoil_sim_hits_coll_name_{"RecoilSimHits"};
198
200 std::string input_pass_name_{""};
201
202 std::string sim_particles_coll_name_;
203 std::string sim_particles_passname_;
204
210
216
221 float z_min_{-999};
222
224 int track_id_{-999};
225
227 double pz_cut_{-9999};
228
230 double p_cut_{0.};
231
233 double p_cut_max_{100000.};
234
235 // Ask for a minimum p for the seeds at the ecal (from truth)
236 double p_cut_ecal_{-1.};
237
238 // Use scoring plane for recoil truth tracks
239 bool recoil_sp_{true};
240
241 // Use scoring plane for target truth tracks
242 bool target_sp_{true};
243
244 // skip the tagger tracker
245 bool skip_tagger_{false};
246
247 // skip the recoil tracker
248 bool skip_recoil_{false};
249
250 // Maximum track id for hit to be selected from target scoring plane
251 int max_track_id_{5};
252
253 std::unique_ptr<const TruthPropagator> propagator_;
254
255 // Track Extrapolator Tool
256 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<TruthPropagator>>
257 trk_extrap_;
258
260 std::string field_map_{""};
261
262 //--- Smearing ---//
263
264 std::default_random_engine generator_;
265 std::shared_ptr<std::normal_distribution<float>> normal_;
266
267 bool seed_smearing_{false};
268
269 std::vector<double> d0smear_;
270 std::vector<double> z0smear_;
271 double phismear_;
272 double thetasmear_;
273 double relpsmear_;
274 std::vector<double> rel_smearfactors_;
275 std::vector<double> inflate_factors_;
276 std::vector<double> beam_origin_{-880.1, -44., 0.};
277 int particle_hypothesis_;
278
279 std::string beam_electrons_collection_;
280 std::string tagger_truth_collection_;
281 std::string recoil_truth_collection_;
282 std::string tagger_seeds_collection_;
283 std::string recoil_seeds_collection_;
284};
285} // namespace tracking::reco
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.
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
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:68
Class representing a simulated particle.
Definition SimParticle.h:25
Represents a simulated tracker hit in the simulation.
Implementation of a track object.
Definition Track.h:54
a helper base class providing some methods to shorten access to common conditions used within the tra...
Create a track seed using truth information extracted from the corresponding SimParticle or SimTracke...
float z_min_
Min cut on the z_ of the scoring hit.
void createTruthTrack(const ldmx::SimParticle &particle, ldmx::Track &trk, const std::shared_ptr< Acts::Surface > &target_surface)
Use the vertex position of the SimParticle to extract (x_, y_, z_, px, py, pz, q) and create a track ...
std::string input_pass_name_
Pass name for the sim hit collections.
std::string recoil_sim_hits_coll_name_
Sim hits to check if the truth seed is findable.
void onNewRun(const ldmx::RunHeader &rh) override
onNewRun is the first function called for each processor after the conditions are fully configured an...
std::vector< int > pdg_ids_
pdg_ids of the particles we want to select for the seeds
void produce(framework::Event &event) override
Main loop that creates the seed tracks for both the tagger and recoil tracker.
int track_id_
Only select a particular trackID.
void configure(framework::config::Parameters &parameters) override
Callback for the EventProcessor to configure itself from the given set of parameters.
double pz_cut_
Ask for a minimum pz for the seeds.
TruthSeedProcessor(const std::string &name, framework::Process &process)
Constructor.
double p_cut_
Ask for a minimum p for the seeds.
void makeHitCountMap(const std::vector< ldmx::SimTrackerHit > &sim_hits, std::map< int, std::vector< int > > &hit_count_map)
Create a mapping from the selected scoring plane hit objects to the number of hits they associated pa...
void onProcessStart() override
Callback for the EventProcessor to take any necessary action when the processing of events starts.
std::string field_map_
Path to the magnetic field map.
std::string scoring_hits_coll_name_
Which scoring plane hits to use for the truth seeds generation.
std::string tagger_sim_hits_coll_name_
Sim hits to check if the truth seed is findable.
ldmx::Track taggerFullSeed(const ldmx::SimParticle &beam_electron, const int trackID, const ldmx::SimTrackerHit &hit, const std::map< int, std::vector< int > > &hit_count_map, const std::shared_ptr< Acts::Surface > &origin_surface, const std::shared_ptr< Acts::Surface > &target_surface)
This method retrieves the beam electron and forms a full seed The seed parameters are the truth param...
virtual ~TruthSeedProcessor()=default
Destructor.
bool scoringPlaneHitFilter(const ldmx::SimTrackerHit &hit, const std::vector< ldmx::SimTrackerHit > &ecal_sp_hits)
Filter that checks if a scoring plane passes specified momentum cuts as well as if the associated Sim...
double p_cut_max_
Ask for a maximum p for the seeds.
int n_min_hits_tagger_
Minimum number of hits left in the recoil tracker to consider the seed as findable.
int n_min_hits_recoil_
Minimum number of hits left in the recoil tracker to consider the seed as findable.
ldmx::Track seedFromTruth(const ldmx::Track &tt, bool seed_smearing)
Create a track seed from a truth track applying a smearing to the truth parameters as well as an infl...