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