LDMX Software
PFTrackProducer.cxx
2
3#include "SimCore/Event/SimParticle.h"
5
6namespace recon {
7
9 inputTrackCollName_ = ps.getParameter<std::string>("inputTrackCollName");
10 input_pass_name_ = ps.getParameter<std::string>("input_pass_name");
11 outputTrackCollName_ = ps.getParameter<std::string>("outputTrackCollName");
12}
13
14double getP(const ldmx::SimTrackerHit& tk) {
15 std::vector<double> pxyz = tk.getMomentum();
16 return sqrt(pow(pxyz[0], 2) + pow(pxyz[1], 2) + pow(pxyz[2], 2));
17}
18
20 if (!event.exists(inputTrackCollName_)) {
21 ldmx_log(fatal) << "Input track collection not found";
22 return;
23 }
24 const auto ecalSpHits = event.getCollection<ldmx::SimTrackerHit>(
25 inputTrackCollName_, input_pass_name_);
26
27 std::vector<ldmx::SimTrackerHit> pfTracks;
28 if (truthTracking_) {
29 for (const auto& spHit : ecalSpHits) {
30 if (spHit.getTrackID() != 1 || fabs(240 - spHit.getPosition()[2]) > 0.1 ||
31 spHit.getMomentum()[2] <= 0)
32 continue;
33 if (spHit.getPdgID() == 22 || spHit.getPdgID() == 2112) continue;
34 pfTracks.push_back(spHit);
35 break;
36 }
37 }
38 std::sort(pfTracks.begin(), pfTracks.end(),
40 return getP(a) > getP(b);
41 });
42 event.add(outputTrackCollName_, pfTracks);
43}
44} // namespace recon
45
46DECLARE_PRODUCER_NS(recon, PFTrackProducer);
#define DECLARE_PRODUCER_NS(NS, 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
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.