LDMX Software
PFTrackProducer.cxx
2
3#include "SimCore/Event/SimParticle.h"
5
6namespace recon {
7
9 input_track_coll_name_ = ps.get<std::string>("inputTrackCollName");
10 input_pass_name_ = ps.get<std::string>("input_pass_name");
11 output_track_coll_name_ = ps.get<std::string>("outputTrackCollName");
12 do_electron_tracking_ = ps.get<bool>("doElectronTracking");
13 min_electron_momentum_z_ = ps.get<double>("minElectronMomentumZ");
14 max_electron_track_id_ = ps.get<int>("maxElectronTrackID");
15}
16
17double getP(const ldmx::SimTrackerHit& tk) {
18 std::vector<double> pxyz = tk.getMomentum();
19 return sqrt(pow(pxyz[0], 2) + pow(pxyz[1], 2) + pow(pxyz[2], 2));
20}
21
23 if (!event.exists(input_track_coll_name_, input_pass_name_)) {
24 ldmx_log(fatal) << "Couldn't find input collection "
25 << input_track_coll_name_ << "_" << input_pass_name_;
26 return;
27 }
28 const auto ecal_sp_hits = event.getCollection<ldmx::SimTrackerHit>(
29 input_track_coll_name_, input_pass_name_);
30
31 std::vector<ldmx::SimTrackerHit> pf_tracks;
32 if (truth_tracking_) {
33 for (const auto& sp_hit : ecal_sp_hits) {
34 if (sp_hit.getPdgID() == 22 || sp_hit.getPdgID() == 2112) continue;
35 if (fabs(240 - sp_hit.getPosition()[2]) > 0.1) continue;
36 if (do_electron_tracking_) { // only select electron SP hits_
37 if (sp_hit.getPdgID() != 11) continue;
38 if (sp_hit.getTrackID() < 2 &&
39 sp_hit.getMomentum()[2] > min_electron_momentum_z_) {
40 // this is almost guaranteed to be a pileup beam electron! keep it
41 pf_tracks.push_back(sp_hit);
42 ldmx_log(debug) << "Added beam electron SP hit: trackID="
43 << sp_hit.getTrackID()
44 << ", pz = " << sp_hit.getMomentum()[2];
45 } else if (sp_hit.getTrackID() <= max_electron_track_id_ &&
46 sp_hit.getMomentum()[2] > 5) {
47 // require more than minimum forward momentum to catch recoil electron
48 // candidates
49 pf_tracks.push_back(sp_hit);
50 ldmx_log(debug) << "Adding SP hit: trackID=" << sp_hit.getTrackID()
51 << ", pdgID= " << sp_hit.getPdgID()
52 << ", pz = " << sp_hit.getMomentum()[2];
53 continue;
54 }
55 } // if electron tracking
56 else {
57 if (sp_hit.getTrackID() != 1 ||
58 fabs(240 - sp_hit.getPosition()[2]) > 0.1 ||
59 sp_hit.getMomentum()[2] < 0)
60 continue;
61 pf_tracks.push_back(sp_hit);
62 ldmx_log(debug) << "Adding SP hit: trackID=" << sp_hit.getTrackID()
63 << ", pdgID= " << sp_hit.getPdgID()
64 << ", pz = " << sp_hit.getMomentum()[2];
65 break;
66 }
67 } // over SP hits_
68 } // do truth tracking
69 std::sort(pf_tracks.begin(), pf_tracks.end(),
71 return getP(a) > getP(b);
72 });
73 event.add(output_track_coll_name_, pf_tracks);
74}
75} // namespace recon
76
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Track selection skeleton for PFlow Reco.
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
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:92
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
Represents a simulated tracker hit in the simulation.
std::vector< double > getMomentum() const
Get the XYZ momentum of the particle at the position at which the hit took place [MeV].
virtual void produce(framework::Event &event)
Process the event and put new data products into it.
virtual void configure(framework::config::Parameters &ps)
Callback for the EventProcessor to configure itself from the given set of parameters.