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/Event/Track.h"
12#include "Tracking/Event/TruthTrack.h"
13#include "Tracking/Reco/TrackExtrapolatorTool.h"
14#include "Tracking/Reco/TrackingGeometryUser.h"
15#include "Tracking/Sim/TrackingUtils.h"
16
17// --- ACTS --- //
18#include <Acts/Propagator/StraightLineStepper.hpp>
19#include <random>
20
21#include "Acts/Definitions/Algebra.hpp"
22#include "Acts/Definitions/TrackParametrization.hpp"
23#include "Acts/EventData/TrackParameters.hpp"
24#include "Acts/Propagator/Navigator.hpp"
25#include "Acts/Surfaces/PerigeeSurface.hpp"
26
27using LinPropagator =
28 Acts::Propagator<Acts::StraightLineStepper, Acts::Navigator>;
29
30namespace tracking::reco {
31
43 public:
51 TruthSeedProcessor(const std::string& name, framework::Process& process);
52
55
66 void configure(framework::config::Parameters& parameters) override;
67
73 void onProcessStart() override{};
74
81 void onNewRun(const ldmx::RunHeader& rh) override;
82
89 void produce(framework::Event& event) override;
90
91 private:
99 void makeHitCountMap(const std::vector<ldmx::SimTrackerHit>& sim_hits,
100 std::map<int, std::vector<int>>& hit_count_map);
101
108 void createTruthTrack(const ldmx::SimParticle& particle, ldmx::Track& trk,
109 const std::shared_ptr<Acts::Surface>& target_surface);
110
119 void createTruthTrack(const ldmx::SimParticle& particle,
120 const ldmx::SimTrackerHit& hit, ldmx::Track& trk,
121 const std::shared_ptr<Acts::Surface>& target_surface);
122
132 void createTruthTrack(const std::vector<double>& pos_vec,
133 const std::vector<double>& p_vec, int charge,
134 ldmx::Track& trk,
135 const std::shared_ptr<Acts::Surface>& target_surface);
136
146 const ldmx::SimTrackerHit& hit,
147 const std::vector<ldmx::SimTrackerHit>& ecal_sp_hits);
148
155 ldmx::Track seedFromTruth(const ldmx::Track& tt, bool seed_smearing);
156
157 ldmx::Track RecoilFullSeed(
158 const ldmx::SimParticle& particle, const int trackID,
159 const ldmx::SimTrackerHit& hit, const ldmx::SimTrackerHit& ecal_hit,
160 const std::map<int, std::vector<int>>& hit_count_map,
161 const std::shared_ptr<Acts::Surface>& origin_surface,
162 const std::shared_ptr<Acts::Surface>& target_surface,
163 const std::shared_ptr<Acts::Surface>& ecal_surface);
164
185 const ldmx::SimParticle& beam_electron, const int trackID,
186 const ldmx::SimTrackerHit& hit,
187 const std::map<int, std::vector<int>>& hit_count_map,
188 const std::shared_ptr<Acts::Surface>& origin_surface,
189 const std::shared_ptr<Acts::Surface>& target_surface);
190
192 Acts::GeometryContext gctx_;
193
195 std::vector<int> pdg_ids_{11};
196
198 std::string scoring_hits_coll_name_{"TargetScoringPlaneHits"};
199
201 std::string tagger_sim_hits_coll_name_{"TaggerSimHits"};
202
204 std::string recoil_sim_hits_coll_name_{"RecoilSimHits"};
205
211
217
222 float z_min_{-999};
223
225 int track_id_{-999};
226
228 double pz_cut_{-9999};
229
231 double p_cut_{0.};
232
234 double p_cut_max_{100000.};
235
236 // Ask for a minimum p for the seeds at the ecal (from truth)
237 double p_cut_ecal_{-1.};
238
239 // Use scoring plane for recoil truth tracks
240 bool recoil_sp_{true};
241
242 // Use scoring plane for target truth tracks
243 bool target_sp_{true};
244
245 // skip the tagger tracker
246 bool skip_tagger_{false};
247
248 // skip the recoil tracker
249 bool skip_recoil_{false};
250
251 // Maximum track id for hit to be selected from target scoring plane
252 int max_track_id_{5};
253
254 std::shared_ptr<LinPropagator> linpropagator_;
255
256 // Track Extrapolator Tool :: TODO Use the real extrapolator!
257 std::shared_ptr<tracking::reco::TrackExtrapolatorTool<LinPropagator>>
258 trk_extrap_;
259
260 //--- Smearing ---//
261
262 std::default_random_engine generator_;
263 std::shared_ptr<std::normal_distribution<float>> normal_;
264
265 bool seedSmearing_{false};
266
267 std::vector<double> d0smear_;
268 std::vector<double> z0smear_;
269 double phismear_;
270 double thetasmear_;
271 double relpsmear_;
272 std::vector<double> rel_smearfactors_;
273 std::vector<double> inflate_factors_;
274 std::vector<double> beamOrigin_{-880.1, -44., 0.};
275};
276} // namespace tracking::reco
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:41
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:54
Class representing a simulated particle.
Definition SimParticle.h:23
Represents a simulated tracker hit in the simulation.
Implementation of a track object.
Definition Track.h:52
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 see...
~TruthSeedProcessor()=default
Destructor.
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...
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.
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 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.
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...
Acts::GeometryContext gctx_
The ACTS geometry context properly.