3#include "SimCore/Event/SimParticle.h"
9 primaryCollName_ = ps.
getParameter<std::string>(
"outputPrimaryCollName");
10 targetCollName_ = ps.
getParameter<std::string>(
"outputTargetCollName");
11 ecalCollName_ = ps.
getParameter<std::string>(
"outputEcalCollName");
12 hcalCollName_ = ps.
getParameter<std::string>(
"outputHcalCollName");
15void sortHits(std::vector<T> spHits) {
16 std::sort(spHits.begin(), spHits.end(),
17 [](T a, T b) { return a.getEnergy() > b.getEnergy(); });
21 if (!event.
exists(
"TargetScoringPlaneHits"))
return;
22 if (!event.
exists(
"EcalScoringPlaneHits"))
return;
23 if (!event.
exists(
"SimParticles"))
return;
24 const auto targSpHits =
26 const auto ecalSpHits =
28 const auto particle_map =
31 std::map<int, ldmx::SimParticle> primaries;
33 std::vector<ldmx::SimTrackerHit> atTarget;
34 std::vector<ldmx::SimTrackerHit> atEcal;
35 std::vector<ldmx::SimTrackerHit> atHcal;
36 for (
const auto &pm : particle_map) {
37 const auto &p = pm.second;
39 if (p.getParents().size() == 1 && p.getParents()[0] == 0) {
40 primaries[pm.first] = p;
41 simIDs.insert(pm.first);
44 for (
const auto &spHit : targSpHits) {
45 if (simIDs.count(spHit.getTrackID()) &&
46 fabs(0.18 - spHit.getPosition()[2]) < 0.1 &&
47 spHit.getMomentum()[2] > 0) {
48 atTarget.push_back(spHit);
51 for (
const auto &spHit : ecalSpHits) {
52 if (simIDs.count(spHit.getTrackID()) &&
53 fabs(240 - spHit.getPosition()[2]) < 0.1 &&
54 spHit.getMomentum()[2] > 0) {
55 atEcal.push_back(spHit);
57 if (simIDs.count(spHit.getTrackID()) &&
58 fabs(840 - spHit.getPosition()[2]) < 0.1 &&
59 spHit.getMomentum()[2] > 0) {
60 atHcal.push_back(spHit);
67 event.add(primaryCollName_, primaries);
68 event.add(targetCollName_, atTarget);
69 event.add(ecalCollName_, atEcal);
70 event.add(hcalCollName_, atHcal);
#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.
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.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Class representing a simulated particle.
Represents a simulated tracker hit in the simulation.
virtual void configure(framework::config::Parameters &ps)
Callback for the EventProcessor to configure itself from the given set of parameters.
virtual void produce(framework::Event &event)
Process the event and put new data products into it.